how can I solve this:
$a = array(9, 10, 11, 12, 13);
$b = array(
array("item" => 10),
array("item" => 13)
);
I want to check what $a values exist in $b['item']. in_array and array_key_exists cannot help me :(
Thanks!
Using a foreach loop will do the work for you.
$not_in_b = array();
foreach($b as $row)
{
if(!in_array($row['item'], $a)
{
$not_in_b[] = $row['item'];
}
}
Try this:
foreach($b as $item){
if(!in_array($item['item'], $a){
echo $item['item'].' is not array $a'; //or do whatever it is you want to do.
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.