[SOLVED] Recognising multi-dim arrays in regexp
Posted: Sat Apr 23, 2005 2:18 pm
Hi, I'm trying to do a preg_replace for multi-dimensional arrays:
<=array[k1][k2]> would be replaced by $array['k1']['k2'] etc - basically <= replaces $ and there's an extra > at the end.
What I have currently is: for a 1-dim array, but I'm certain that it could be modified to handle any type of variable or array.
I'm trying this regexp: but it returns an "unexpected less-than or equal sign" error. I have a feeling it's related to the brackets being in the parentheses.
Any ideas what I can do to make it work?
<=array[k1][k2]> would be replaced by $array['k1']['k2'] etc - basically <= replaces $ and there's an extra > at the end.
What I have currently is:
Code: Select all
$index_content = preg_replace("/<=([_a-z0-9]+)\[([_a-z0-9]+)\]>/ie", "$$1[$2]", $index_content);I'm trying this regexp:
Code: Select all
/<=(ї_a-z0-9]+)(\її_a-z0-9]\]*)>/ieAny ideas what I can do to make it work?