php - regex to array in parentheses -
hello have question having issue find solution works
basically in string have text
anim(10, <-0.016, -0.006, 0.217>, <0.000, 0.000, 0.707, 0.707>, <0.016, 0.010, 0.012>);
what looking accomplish break downwards array
something
array( 0 => 'anim', 1 => '10', 2 => '<-0.016, -0.006, 0.217>', 3 => '<0.000, 0.000, 0.707, 0.707>', 4 => '<0.016, 0.010, 0.012>' );
so can prepare info send script utilize have special functions create easier users use.
hope can help far managed to break downwards 2 arrays need them on each line of array can run loops prepare data
stephen
you can utilize regex in preg_match_all
:
(<[^>]*>|\w+)
code:
$re = '/(<[^>]*>|\w+)/'; $str = "anim(10, <-0.016, -0.006, 0.217>, <0.000, 0.000, 0.707, 0.707>, <0.016, 0.010, 0.012>);"; preg_match_all($re, $str, $matches);
regex demo php arrays regex
No comments:
Post a Comment