3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = array( array( 'url' => '/', 'text' => 'Dashboard', array( 'url' => '/routes/', 'text' => 'Routes', array( 'url' => '/routes/directions/', 'text' => 'Directions' ), array( 'url' => '/routes/blocks/', 'text' => 'Blocks' ), array( 'url' => '/routes/headsigns/', 'text' => 'Headsigns' ), ), array( 'url' => '/fares/', 'text' => 'Fares', array( 'url' => '/fares/zones/', 'text' => 'Zones' ), array( 'url' => '/fares/fares/', 'text' => 'Rules' ) ) ) ); $needle = 'Dashboard'; $key = array_search($needle, array_column($haystack, 'text')); echo 'key = ' . $key . '<br />'; // result = 0 $needle = 'Dashboard'; $key = array_search($needle, array_column($haystack, 'text')); echo 'key = ' . $key . '<br />'; // result =

preferences:
53.26 ms | 402 KiB | 5 Q