For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > February 2007 > Re: [PHP-DB] Strange action with =&









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Strange action with =&
bedul

2007-02-13, 3:58 am

sry i don't get what u mean??
----- Original Message -----
From: "Peter Beckman" <beckman@purplecow.com>
To: "PHP-DB Mailing List" <php-db@lists.php.net>
Sent: Tuesday, February 13, 2007 8:29 AM
Subject: [PHP-DB] Strange action with =&


> I'm looping through an array and I did this:
>
> $rate =& $mydata[$prefix];
>
> Now, in some cases $mydata[$prefix] wasn't set/defined, so I expected

$rate
> to not be defined, or at least point to something that wasn't defined.
>
> Instead, PHP 5.1.6 set $mydata[$prefix] to nothing.
>
> If I had:
>
> $mydata[1] = 3;
> $mydata[3] = 2;
> $mydata[5] = 1;
>
> And did a loop from $i=1; $i++; $i<=5 I'd get:
>
> $mydata[1] = 3;
> $mydata[2] = ;
> $mydata[3] = 2;
> $mydata[4] = ;
> $mydata[5] = 1;


the reason mydata2 empty was because it don't have value in it!!

full source plz
why u don't try this

$txt.="<ol>";
foreach($mydata as $nm=>$val){
$txt.="\n<li> $nm = $val";
$txt2="<br>\$mydata[$nm] = $val";
}
$txt.="</ol>";

print $txt;

>
> Is this expected? A bug? Fixed in 5.2.0? I know I shouldn't set a
> reference to a variable that doesn't exist, but the expected result is a
> warning/error, not for PHP to populate an array.


we should cross check again.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com