You are here: Re: How to iterate throut an array? « PHP Programming Language « IT news, forums, messages
Re: How to iterate throut an array?

Posted by mootmail-googlegroups on 08/09/06 19:26

talthen.z-serwera.o2@nospam.pl wrote:

> The function looks like this:
>
> function Del(&$tresc)
> {
> if (is_array($tresc['T'])) Del($tresc['T']);
> else if (!$tresc['T'])
> {
> for ($x=0;$x<count($tresc);$x++)
> {
> Del($tresc[$x]); //THIS IS LINE 51
> }
> }
> else if (($tresc['Co']['C']=='hl') and
> (!$tresc['Co']['n']))
> array_splice($tresc,0,1);
> }
>
> How to iterate through all elements and delete some of them?
>
> Regards,
> Talthen

Well, I'm not sure if it is causing the specific error you mentioned,
but one of your problems is the line:
for ($x=0;$x<count($tresc);$x++)

In the array you gave as an example, you have some non-numeric key
values. Iterating a variable in order to do $tresc[$x] only works if
you have integer keys in order, such as
$tresc[0],$tresc[1],$tresc[2]...etc. For non-numeric keys, use the
foreach control structure.

 

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

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