I have $view_data['auth_info']
which is populated with a query row, that works fine. But i need to add an additional row to this array. How is this possible? All the variables are unique, so theres no change i will have to identical definitions.
I tried following:
$view_data['auth_info'] = $myFirstSQLRow
array_push($view_data['auth_info'],$mySecondSQLRow);
But it failed:
Message: array_push() [function.array-push]: First argument should be an array
But isnt the first var an array
or have i misunderstood something?
You are looking for array_merge
. Use it like this:
$view_data['auth_info'] = $myFirstSQLRow;
$view_data['auth_info'] = array_merge($view_data['auth_info'], $mySecondSQLRow);
As it says in the documentation, you may need to type-cast (by putting (array)
in front of your variables.)