... I just thought I would see if anyone else can reproduce it!

Ok. The problem is in the following snippet of code. ( Note : this exmaple
is extremely contrived, and is the essence of a much more complicated
situation involving a function call from a class method... )

<?php
     $data = array( "A" => "AA" , "B" => "BB", "C"=> "CC", "D"=> "DD", "E" 
=> "EE" );

     print "<pre>\n";
     foreach ( $data as $key1=>$val1 )
     {
//        foreach ( $data as $key2=>$val2 )
         foreach ( array_keys($data) as $key2 )   // <= PROBLEM IS HERE
         {
             if ( $key1 == $key2 )
                 print "<b>$key2</b>";
             else
                 print $key2;

             print "  ";
         }
         print "\n";
     }

     print "</pre>";
?>

I beleive it should generate
<pre>
<b>A</b>  B  C  D  E
A  <b>B</b>  C  D  E
A  B  <b>C</b>  D  E
A  B  C  <b>D</b>  E
A  B  C  D  <b>E</b>
</pre>

Instead it generates
<pre>
<b>A</b>  B  C  D  E
</pre>

If I replace the problem line
         foreach ( array_keys($data) as $key2 )

with the alternate
         foreach ( $data as $key2=>$val2 )

then it works fine.

I am using PHP 4.0.4pl1.


Regs

Brian White

-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to