3v4l.org

run code in 300+ PHP versions simultaneously
<?php $id=5; $allProducts[] = array('itemid'=>$id,'qty' => 1); $allProducts[] = array('itemid'=>6,'qty' => 1); // old version if(array_search($id,array_column($allProducts, 'itemid'))) { echo "an item was found\n"; // will not work } else { echo "NO Item was found, though it should be there\n"; } // corrected version if(array_search($id,array_column($allProducts, 'itemid')) !== false) { echo "an item was found and has the key " .array_search($id,array_column($allProducts, 'itemid')); }

preferences:
59.37 ms | 402 KiB | 5 Q