3v4l.org

run code in 300+ PHP versions simultaneously
<?php function findInArray($query, $data) { foreach ($query as $key) { if (!array_key_exists($key, $data)) { // The key was not found, set data to null and abort $data = null; break; } // Set data to the next level $data =& $data[$key]; } return $data; } $response = [ 'client1' => [ 'dog' => [ 'Jack' => 'Some value', 'Jack1' => 'Some value1', 'Jack2' => [ 'name' => 'Yes!', 'working' => [ 0 => 'Nope...', 1 => 'Seems like it!' ], ], ], ], 'client2' => [ 'cat' => [ 'Stacy' => 'Some other value', ], ], ]; $query = ['dog', 'Jack2', 'working', 1]; var_dump(findInArray($query, $response['client1']));
Output for git.master, git.master_jit, rfc.property-hooks
string(14) "Seems like it!"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
140.09 ms | 405 KiB | 5 Q