You are here: Re: Searching through an array « All PHP « IT news, forums, messages
Re: Searching through an array

Posted by John Rappold on 08/22/06 15:44

-Lost,

Thanks, that worked well.

So that i can learn something and not have to ask a question in the same
context, again, could you walk me through what these lines are doing:

for($i = 0; $i < count($fields); $i++)
{
for($j = 0; $j < count($badchars); $j++)


I understand that I have to traverse through both arrays, but I'm not sure
what you did in the above lines.

Later,
jr
"-Lost" <spam_ninjaREMOVEME@REMOVEMEcomcast.net> wrote in message
news:9rqdncF-r5QiQHfZnZ2dnUVZ_q6dnZ2d@comcast.com...
> "John Rappold" <jrappold@jscoca-k12.org> wrote in message
> news:IKmGg.20285$uV.15613@trnddc08...
>
>> $dirn = substr($file, 0, 6);
>> $birn = substr($file, 7, 6);
>> $fdate = substr($file, 14, 8);
>> $period = substr($file, 23, 5);
>> $cat = substr($file, 29, 3);
>>
>> $fields = array($dirn, $birn, $fdate, $period, $cat);
>>
>> $badchars = array("-", "_");
>
> How about:
>
> for($i = 0; $i < count($fields); $i++)
> {
> for($j = 0; $j < count($badchars); $j++)
> {
> if(strpos($fields[$i], $badchars[$j]) === false)
> {
> continue;
> }
> else
> {
> print $fields[$i] . ' contained ' . $badchars[$j] . '<br />' . "\n";
> }
> }
> }
>
> It may not be the most elegant solution, and using regular expressions
> might make it considerably easier, but hey... it works efficiently.
>
> -Lost
>

 

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

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