3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $long_string = '"name" => "Able","company" => "Tesla","haircolor" => "brown","name" => "Aaaa","home" => "Kansas","shoe" => 12<>"name" => "Bob","company" => "Target","haircolor" => "red","name" => "Bbbb","home" =>"Ohio","shoe" => 11.5'; function multiexplode ($delimiters,$string) { $ary = explode($delimiters[0],$string); array_shift($delimiters); if($delimiters != NULL) { foreach($ary as $key => $val) { $ary[$key] = multiexplode($delimiters, $val); } } return $ary; } // Example of use // $string = "1-2-3|4-5|6:7-8-9-0|1,2:3-4|5"; // $delimiters = Array(",",":","|","-"); $delimiters = Array("<>",","); $res = multiexplode($delimiters,$long_string); echo '<pre>'; print_r($res); echo '</pre>';
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
<pre>Array ( [0] => Array ( [0] => "name" => "Able" [1] => "company" => "Tesla" [2] => "haircolor" => "brown" [3] => "name" => "Aaaa" [4] => "home" => "Kansas" [5] => "shoe" => 12 ) [1] => Array ( [0] => "name" => "Bob" [1] => "company" => "Target" [2] => "haircolor" => "red" [3] => "name" => "Bbbb" [4] => "home" =>"Ohio" [5] => "shoe" => 11.5 ) ) </pre>