最简单的问题:从数组提取值 [英] The simplest question: extract values from array
本文介绍了最简单的问题:从数组提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,这是一个例子:
阵列(
[0] =>阵列([标题] => TITLE_1 [结帐] => 1 [no_gateway] = 0)
[1] =>阵列([标题] => TITLE_2 [结帐] => 1 [no_gateway] => 1)
[2] =>阵列([标题] => TITLE_3 [结帐] => 0 no_gateway] = 0)
[3] =>阵列([标题] => Title_4 [结帐] => 1 [no_gateway] => 1)
[4] =>阵列([标题] => Title_5 [结帐] => 0 no_gateway] = 0)
[5] =>阵列([标题] => Title_6 [结帐] => 1 [no_gateway] = 0)
)
我要打印出来,其[结账] => 1安培在[标题]键的所有值; [no_gateway] => 0
在我的情况下,它应该看起来像
- TITLE_1
- Title_6
请帮助PHP的初学者:)谢谢!
解决方案
的foreach($数组作为$行){
如果($行['结账']&放大器;&安培;!$行['no_gateway']){
打印$行['标题'];
}
}
So this is an example:
Array (
[0] => Array ( [title] => Title_1 [checkout] => 1 [no_gateway] => 0 )
[1] => Array ( [title] => Title_2 [checkout] => 1 [no_gateway] => 1 )
[2] => Array ( [title] => Title_3 [checkout] => 0 [no_gateway] => 0 )
[3] => Array ( [title] => Title_4 [checkout] => 1 [no_gateway] => 1 )
[4] => Array ( [title] => Title_5 [checkout] => 0 [no_gateway] => 0 )
[5] => Array ( [title] => Title_6 [checkout] => 1 [no_gateway] => 0 )
)
I need to print out all values under [title] key having [checkout] => 1 & [no_gateway] => 0
In my case it should looks like
- Title_1
- Title_6
Please help php-beginner :) Thanks!
解决方案
foreach($array as $row) {
if ($row['checkout'] && !$row['no_gateway']) {
print $row['title'];
}
}
这篇关于最简单的问题:从数组提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文