As the title sugests , i have a functions , i make a few changes to an array( this array is my paramether ). Then i realized that i used a copy of my actual array.
I know there was a way to get the actual array and not a copy , what was it ?
Thank you all in advance , i know you will solve this in a jiffy 🙂
Here is where i use it
function findChildren($listOfParents)
{
static $depth=-1;
$depth++;
foreach ($listOfParents as $thisParent)
{
$thisParent->title = str_repeat(" >", $depth) . $thisParent->title;
$children = page::model()->findAll(array('condition'=>'parent = ' . $thisParent->id));
findChildren($children);
}
$depth--;
}
So i need this $listOfParents, not his copy.
Try passing the value by reference
Notice the ampersand
&, which indicates you are working on the original variable, not a copy.