Im trying to insert variables to the array by using foreach loop. This is the foreach loop im trying to implement with
foreach($rows as &$url) {
$link = array("url");
array_push($url, "hello World");
}
And this is the result I get.
Array
(
[0] => Array
(
[cat_id] => 1
[id] => RT
[name] => root
[parent] => 0
[0] => hello World
)
[1] => Array
(
[cat_id] => 2
[id] => CI
[name] => Civil & Interior Works
[parent] => 1
[0] => hello World
)
)
but i would like the result to be like this.
Array
(
[0] => Array
(
[cat_id] => 1
[id] => RT
[name] => root
[parent] => 0
[url] => hello World
)
[1] => Array
(
[cat_id] => 2
[id] => CI
[name] => Civil & Interior Works
[parent] => 1
[url] => hello World
)
)
If i pass the variable $link = array("url"); to array_push($link, "hello World"); nothing happens.
if I remove the referance from the foreach($rows as &$url) the loop does not work at all. Please advise.