3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = ["cat:others;id:4,9,13", "id:4,9,13;cat:electric-products", "id:4,9,13;cat:foods", "cat:drinks,foods"]; foreach ($strings as $key=>$string) { $temps = explode(';', $string); $cats = []; $ids = []; foreach ($temps as $temp) { $tempnest = explode(':', $temp); if ($tempnest[0] === "cat") { $cats = explode(',', $tempnest[1]); } if ($tempnest[0] === "id") { $ids = explode(',', $tempnest[1]); } } print_r($cats); print_r($ids); }
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => others ) Array ( [0] => 4 [1] => 9 [2] => 13 ) Array ( [0] => electric-products ) Array ( [0] => 4 [1] => 9 [2] => 13 ) Array ( [0] => foods ) Array ( [0] => 4 [1] => 9 [2] => 13 ) Array ( [0] => drinks [1] => foods ) Array ( )

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