My code below creates an error, unknown modified "|" ... I am trying to use it as an OR statement. What is the correct way to run this code without errors?
$p = "(\w+)|(\()|(\))|(\,)"; $s = "sum(blue,paper,green(yellow,4,toast)))"; preg_match($p,$s, $matches); print_r($matches);
Edit
Ok, I changed it a little ... ~(\w+|\(|\)|,)~
Now ... here is the problem: I need to take this line and split it into an array like this:
array("sum","(","blue","paper","green","(" ... etc );
Can someone help me do this? when I run the expression above, it outputs an empty array ....
thanks
source share