You are here: Re: [PHP] Arrays « PHP « IT news, forums, messages
Re: [PHP] Arrays

Posted by Justin Gruenberg on 07/12/05 14:43

On 12/07/05, virtualsoftware@gmail.com <virtualsoftware@gmail.com> wrote:
> Hi,
>
> How can i destroy an array?
> I mean i have a loop and for each new value in the loop i want to destroy the array. Something like that:
>
> while($row = mysql_fetch_array($result))
> {
>
> $product[] = $product_id;
>
> // some code here
>
> }
>
> I've tried this but doesn't work
>
> while($row = mysql_fetch_array($result))
> {
>
> $product = array();
>
> $product[] = $product_id;
>
> // some code here
>
> }


To destroy an array?

First of all, where does $product_id come from? You gave us no code
that gives us that.

Second, if you're trying to make an array populated with a feild from
each row returned, your first example will work, but not the second.
The second example will empty the array, and start a new one (which
doesn't make sense to me why you would do that--because in the end,
you're only going to have the array with the last row returned).

But if you're trying to destroy an array doing either:
unset($an_array)
or $an_array = array();
will do the job.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация