3v4l.org

run code in 300+ PHP versions simultaneously
<?php $txt = "3000,MELBOURNE 3001,MELBOURNE 3002,EAST MELBOURNE 3003,WEST MELBOURNE 3603,WEST SYDNEY 3103,NORTH PERTH"; $rows = explode(PHP_EOL, $txt); $arr= []; foreach($rows as $row){ List($postcode, $suburb) = explode(",", $row); If(in_array(substr($suburb,0,4), array("EAST", "WEST")) || in_array(substr($suburb,0,5), array("SOUTH", "NORTH"))){ $temp = explode(" ", $suburb); $arr[$temp[1]][$temp[0]][] = $postcode; }else{ $arr[$suburb][] = $postcode; } } Var_dump($arr);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["MELBOURNE"]=> array(4) { [0]=> string(4) "3000" [1]=> string(4) "3001" ["EAST"]=> array(1) { [0]=> string(4) "3002" } ["WEST"]=> array(1) { [0]=> string(4) "3003" } } ["SYDNEY"]=> array(1) { ["WEST"]=> array(1) { [0]=> string(4) "3603" } } ["PERTH"]=> array(1) { ["NORTH"]=> array(1) { [0]=> string(4) "3103" } } }

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:
37.31 ms | 402 KiB | 8 Q