I'm trying to split a string with multiple delimiters using the PHP preg_split function.
I am trying to separate the numbers from the units in terms like 172px, 100%, 2.5ems etc...
i.e. after I run a preg_split on 172px I want the resulting array to have array = 172 and array = px
Here is the code I've used so far:
$test = preg_split('(px)(em)(pt)(%))','128px','-1', PREG_SPLIT_DELIM_CAPTURE); echo $test;
However, this echos out the entire thing eg: 128px
If I try something like this,
$test = preg_split('(px)|(em)|(pt)|(%))','128px','-1', PREG_SPLIT_DELIM_CAPTURE); echo $test;
It works perfectly if I search for 128px. However, it fails for everything else like 128em or 128%.