Hi,

 

While programming I stumbled across this - can anyone reproduce this, or is it 
just a bug in my system? Replacing the $currtag in the final foreach loop with 
&$currtag causes it to behave as expected, but the code as pasted below is 
obviously badly dysfunctional. Is anyone able to shed some light on this?

 

Cheers,

Steve

 

-------------------------------------

<?php

$tags = array(
        'Item1',
        'Item2'
);

foreach($tags as &$currtag) {
        $currtag = array($currtag, 0);
}

print_r($tags);
foreach($tags as $currtag) {
        print_r($tags);
}

?>
----------------------------------

 

That code gives the following output:

 

Array
(
    [0] => Array
        (
            [0] => Item1
            [1] => 0
        )

    [1] => Array
        (
            [0] => Item2
            [1] => 0
        )

)
Array
(
    [0] => Array
        (
            [0] => Item1
            [1] => 0
        )

    [1] => Array
        (
            [0] => Item1
            [1] => 0
        )

)
Array
(
    [0] => Array
        (
            [0] => Item1
            [1] => 0
        )

    [1] => Array
        (
            [0] => Item1
            [1] => 0
        )

)
 

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to