3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = '(Mary Poppens) Umbrella (Color Yellow)'; preg_match_all('#\((.*?)\)|[^()]+#', $string, $match, PREG_SET_ORDER); foreach($match as $m){ if(isset($m[1])){ $array[] = explode(' ', $m[1]); }else{ $array[] = trim($m[0]); } } print_r($array); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Array ( [0] => Mary [1] => Poppens ) [1] => Umbrella [2] => Array ( [0] => Color [1] => Yellow ) )