It seems like it should be that simple, but regular expressions really confuse me. I grab the $ _GET variables, which will look like typeX, optionX, groupX, etc., where X is equal to any positive integer. I need to split the string into an integer so that type1 becomes an array of "type" and "1", however type10 must become an array of "type" and "10" not "type" and "1" and "0".
I am completely unfamiliar with regex patterns, but ended up with:
$array = preg_split("#\\d+#", $key, -1, PREG_SPLIT_NO_EMPTY); print_r($array);
but he just removed the number from the end, and did not split the string into two arrays, as was shown as a result:
Array ( [0] => type )
Also, I'm not sure, as if it would further divide the number ten into one and zero, which I don't want. I feel that this is probably just a mind-blowing decision, but I'm circling here.
source share