views:

278

answers:

2

Is it possible to array_push to a multidimensional array?

Creating the array using:

$ObjectArray = array();
$ShiftArray = array($ObjectArray);
$WeekShiftArray = array($ShiftArray);
$MasterShiftArray = array($WeekShiftArray);

And trying to push to the array using

array_push($MasterShiftArray[$last_monday_from_date][$CurrentShift->Offset][$CurrentShift->Shift], $CurrentShift);

But I'm getting:

Warning: array_push() expects parameter 1 to be array, object given in /opt/lampp/htdocs/sandboxj/blog/wp-content/plugins/Shifty/AddShift.php on line 94

Any help would be appreciated.

A: 
fireeyedboy
A: 

you could just do

$MasterShiftArray[$last_monday_from_date][$CurrentShift->Offset][$CurrentShift->Shift][] = $CurrentShift;
Tor Valamo