PHP Object References?
I've read up about PHP variable references but I'm not 100% and was hoping
someone could help.
If I have a class like the following:
class Item
{
public $value;
}
I then have an array of those items in a variable - lets call that $items.
All I did was new Item()...and $items[] = $newItem;.
Now, I want to populate another array but it filters the original array
based on its value. So like the following:
foreach($items as $key => $value)
{
$filteredItems[] = &value;
}
Now, I have ANOTHER variable that iterates over that filtered list and
does something like so:
$theItem = $filteredItems[10];
$theItem->value = 100;
Now this is where I'm confused. Do I need to set $theItem to
&filteredItems[10]; (reference) or will it just know that the value in the
array is a reference type and $theItem also becomes a reference to that
same item? I'm after that last set of $theItem->value = 100; changes the
very original object stored in the $items list.