<?php
$row = 'Foo';
echo "What is \$row?\n";
var_dump($row);
$rows = ['Hello', 'Test', 'Wow'];
echo "Lets print each value in \$rows as \$row by reference\n";
foreach($rows as &$row)
{
var_dump($row);
}
echo "Now lets run the same thing again, only this time not as reference\n";
foreach ($rows as $row)
{
var_dump($row);
}
echo "And print \$row for the sake of it\n";
var_dump($row);
What is $row?
string(3) "Foo"
Lets print each value in $rows as $row by reference
string(5) "Hello"
string(4) "Test"
string(3) "Wow"
Now lets run the same thing again, only this time not as reference
string(5) "Hello"
string(4) "Test"
string(4) "Test"
And print $row for the sake of it
string(4) "Test"