I have an input (a posted variable called SIMsubmit) that looks like this (out to 121 variations- it represents data found in a table that can be anywhere from 6x6 to 11x11, but that's not really relvant to my question):
x27y39r6g4;x28y39r11g26;x29y39r9g14;x30y39r4g13;x31y39r6g4;x32y39r13g6;x33y39r0g5;
I'm trying to process this into 4 arrays that list the values found after each x, y, r, and g. Here's the code I'm using:
$SIMsubmit = $_POST['SIMsubmit'];
$xMatches = preg_match_all ( '/(x\d+)(y\d+)(r\d+)(g\d+);/' , $SIMsubmit , $submitXYRGs, PREG_PATTERN_ORDER);
$submitXs = $submitXYRGs[1];
$submitYs = $submitXYRGs[2];
$submitRs = $submitXYRGs[3];
$submitGs = $submitXYRGs[4];
When I go to use the variables ($submitXs, $submitYs, $submitRs, $submitGs) I expect them to be arrays, but I'm getting errors that seem to indicate they are not. What's up? I suspect I'm just not quite understanding how preg_match_all arranges the matches in the variable $submitXYRGs, although my mistake may be more elementary...
There may be a better way to do this whole process, but I figure I'd like to stick with having 4 arrays, each with the same length, arranged so that the index (n) of one array corresponds to the index(n) of the others. With the above code even do that? If not, how would I do so?