3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sales_people = array( '2' => array( 'states' => array('NY', 'NJ', 'CT', 'MA', 'VT', 'ME'), 'codes' => array('CA1', 'US7', 'UT9') ), '5' => array( 'states' => array('FL', 'GA', 'SC', 'NC', 'TN'), 'codes' => array('VA4', 'VA8', 'VA3') ) ); function populateLookup(array $sets): array { $lookup = []; foreach ($sets as $id => $haystacks) { foreach ($haystacks as $haystack) { $lookup += array_fill_keys($haystack, $id); } } return $lookup; } $map = populateLookup($sales_people); var_export($map); echo "\n---\n"; var_export($map['CT'] ?? null);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'NY' => 2, 'NJ' => 2, 'CT' => 2, 'MA' => 2, 'VT' => 2, 'ME' => 2, 'CA1' => 2, 'US7' => 2, 'UT9' => 2, 'FL' => 5, 'GA' => 5, 'SC' => 5, 'NC' => 5, 'TN' => 5, 'VA4' => 5, 'VA8' => 5, 'VA3' => 5, ) --- 2

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:
34.68 ms | 406 KiB | 5 Q