I am trying to nest a for loop inside a multidimensional while it is being constructed. The new array is being built from other arrays. I need the data to exist as a block of data while I perform some actions on it (re-sort based on time). An array seemed the logical way to do it.
Here is my code. It is failing with the following error - syntax error, unexpected ‘for’ (T_FOR), expecting ‘)’. The identified line is the one starting with for.
Quick response while working, sorry if it’s inaccurate. You can’t do a loop inside of an actual array declaration. You can however create the array as an empty one, and then add individual items (in this case, more arrays) as array items. It could look (something) like this? Without knowing where this data comes from, what LaneAssignment and RaceResultsArray are, it’s hard to know what you need?
gidday: I dont know why you want to store $x ?
jeffrey: the $result variable is actually redundant here, just do a straight assignment of $RaceResults.
Pepster: I’m going to assume that the value coming out of $RaceResultsArray is the time; as $x is an integer 0-6 and lane assignment seems to be irrelevant data as well; also, his example shows he is not using associative arrays (though it may be beneficial for him to do so);