I want to split a string in PHP into a 'name' part (string) and a 'keys' part (array of integers).
Example input:
$input = "Sum(1, 5, 7)";
Desired output:
$name = "Sum";
$keys = [1, 5, 7];
I've been looking at explode, str_split preg_split, and I'm sure there are many possible implementations. What's the most elegant solution?
Sum(1, Sum(1, 5, 7), 7)? What's the expected output ?Sum(1, 5, 7)or could there be several "parts" likeSum(1, 5, 7) , Div(10, 5), Mul(3, 4)?