I have the following PHP Array:
$mod = array( 1 => array(), 2 => array(), 3 => array());
When I json_encode $mod, it produces this:
{"1":[],"2":[],"3":[]}
But I want to be able to do this in the following manner:
$tstarray = array();
$newaray = array(1 => array());
$newaray2 = array(2 => array());
$newaray3 = array(3 => array());
array_push($tstarray, $newaray);
array_push($tstarray, $newaray2);
array_push($tstarray, $newaray3);
When I json_encode $tstarray, it produces a result like this:
[{"1":[]},{"2":[]},{"3":[]}]
I want the second result to look like the first result. By "look" I mean the same type. Do you know what I would need to change in order to get this to be the same?
Update: What end result do I need?
If I have var x = 9 Then I need a while loop that will create the $mod variable but do it all the way from 1 => array() to 9 => array(). How would I do this?