I want to have a numerical, multidimensional array of scores. The first index is the page load, and the second is the score value for the particular question. When I push to the array, the load value is already def开发者_如何转开发ined.
I keep getting this error: Warning: array_push() expects parameter 1 to be array, null given in (...)
I'm guessing there's an issue with how I declared the array in the first place, but I've also tried array() and array()array() and neither of those worked. My search skills are failing me, and I'm out of ideas. Here's the relevant code:
if (!isset($_SESSION['scores'])) {
$_SESSION['scores'] = array(array());
}
if ($users[$i] == $useSet[$i+2]) {
array_push($_SESSION['scores'][$_SESSION['load']], 'c');
}
Try using square bracket syntax instead:
$_SESSION['scores'][$_SESSION['load']][] = 'c';
精彩评论