<?php $string = '[1,[01,11,12] ,4 ,5, [20,21,22]]'; $parts = preg_split('/,(?![^\[]*\])/', $string, -1, PREG_SPLIT_DELIM_CAPTURE); $output = array(); foreach ($parts as $part) { $part = trim($part, '[] '); $output[] = explode(',', $part); } print_r($output);
You have javascript disabled. You will not be able to edit any code.