SV: HELP - Clean and simple

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----Ursprungligt meddelande-----
Från: rabin.vincent@xxxxxxxxx [mailto:rabin.vincent@xxxxxxxxx]För Rabin
Vincent
Skickat: den 22 maj 2006 16:26
Till: Jonas Rosling
Kopia: PHP List
Ämne: Re:  HELP - Clean and simple


On 5/22/06, Jonas Rosling <webmaster@xxxxxxxxxxxx> wrote:
> :-) Sorry! I've been digging with this for a while now so I don't think I
> have the best code left. But this is what I have for the moment:
>
> while($row=mysql_fetch_array($result)) {
>
>         if (!$$row[0]) {
>
>                 $$row[0] = array();
>
>                 $$row[0][$row[2]] = $row[1];
>
>         }
>
>         else {
>
>                 $$row[0][$row[2]] = $row[1];
>
>         }
>
> }
>
> I've been trying with eval() a bit as well without any good result.

The above code will work properly if you surround the
dynamic variable names by curly brackets:

    ${$row[0]}[$row[2]] = $row[1];

Rabin

Thank you Rabin very much!!! It was just { } that was missing. Not so easy
to know what to do to get some things to work when you're rather new  at it.

// Jonas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux