我有一个数组
$main_array = [
["image" => "james.jpg", "name" => "james", "tag" => "spacey, wavy"],
["image" => "ned.jpg", "name" => "ned", "tag" => "bright"]
["image" => "helen.jpg", "name" => "helen", "tag" => "wavy, bright"]
]
我使用 aforeach根据 的值回显一些 HTML tag。像这样的东西
foreach($main_array as $key => $array) {
if ($array['tag'] == "bright") {
echo '<p>'.$array['name'].' '.$array['image'].' '.$array['tag'].'</p>';
}
}
这只会输出“ned”作为匹配标签“bright”。但它也应该输出“海伦”。相似地:
foreach($main_array as $key => $array) {
if ($array['tag'] == "wavy") {
echo '<p>'.$array['name'].' '.$array['image'].' '.$array['tag'].'</p>';
}
}
应该输出“james”和“helen”。我需要什么样的功能才能达到预期的效果?
互换的青春
扬帆大鱼