3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 91 => array ( 'description' => 'Charged', 'boundingPoly' => array ( 'vertices' => array ( 0 => array ( 'x' => 244, 'y' => 438 ), 1 => array ( 'x' => 287, 'y' => 438 ), 2 => array ( 'x' => 287, 'y' => 452 ), 3 => array ( 'x' => 244, 'y' => 452 ), ')))' ) ) ) ); $x = 244; foreach ($array as $box) { if (in_array($x, array_column($box['boundingPoly']['vertices'], 'x'))) { $descr = $box['description']; break; } } if (isset($descr)) { echo "found $descr with x = $x\n"; }
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
found Charged with x = 244
Output for 5.2.17
Fatal error: Call to undefined function array_column() in /in/2dJbv on line 39
Process exited with code 255.

preferences:
146.52 ms | 406 KiB | 5 Q