I am stumbling on something annoying and hope you can shed some light. I am generating an array via PHP MySQL query. My WHILE statement is as follows:
$model[constraints][d][] = array($row['Node'] => array("max" => $row['dem'], "min"=> $row['dem']));
The problem is that each new array added to $model[constraints][d] gets enclosed by an array. See screenshot below:

I don't want there to be array "0" around Norway. I would like to be able to access my values as follows:
$model[constraints][s][Norway][max]
Right now, the only way I can access that value is by doing the following:
$model[constraints][s][0][Norway][max]
How should I amend my while statement to get the desired array? Thank you for your time.
Before the loop you could do:
$model[constraints][d] = array();
And then just change the statement inside the loop to:
$model[constraints][d] += array($row['Node'] => array("max" => $row['dem'], "min"=> $row['dem']));
Here's a live demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With