PHP检查值是否存在于另一个数组中 [英] php check if value exsist in array, in another array
本文介绍了PHP检查值是否存在于另一个数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组dataImages,它保存图像信息的数组,看起来像这样
I have a array dataImages which holds the arrays of image informations and looks like this
Array (
[0] => Array (
[id] => 104
[name] => sample-large-Test-1-a52d268be9ad9c.png
[user] => 31
[main_image] => 1
)
[1] => Array (
[id] => 105
[name] => sample-large-Test-1-a52d268bee6ba5.jpg
[user] => 31
[main_image] => 0
)
[2] => Array (
[id] => 106
[name] => sample-large-Test-1-a52d268bf4c457.jpg
[user] => 31
[main_image] => 0
)
)
如何检查数组dataImages
中是否为带有main_image === 1
的图像?如何显示该图像的数据?
How can i check if in array dataImages
is an image with main_image === 1
and how can i show data for that image?
推荐答案
您还可以循环执行此操作:
You can do this in loop also:
foreach ($dataImages as $image){
if ($image['main_image']) print_r($image)
}
这篇关于PHP检查值是否存在于另一个数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文