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

Posted by Phil on 08/21/06 18:44

On Mon, 21 Aug 2006 18:15:04 GMT, John Rappold wrote...
>
>Hi,
>
>I could really use some fast help on this. I have two arrays.
>The first array is created from the following:
>
> $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);
>
>Here's the second array:
>
>$badchars = array("-", "_");
>
>What I want to do is search through the $fields array and find any
>occurences of the characters in the $badchars array.
>
>I tried to use an example from some comments on the PHP manual strpos page,
>but I can't get this to work:
>$i=0;
>$offset=0
>$pos=false;
>if ($pos === false) {
>$pos = strpos($fields, $badchars[$i], $offset);
>echo "File Passed.<br> ";
>$i++;
>} else {
>rename($curpath, $badpath);
>echo "Bad file Moved<br>";
>$i++;
>}TIA for help on this.
>
>


You might need to do a "for" loop so all the items in your $badcahars array get
checked. It looks like you have $i defined as 0 and not checking the rest of
that array.

Phil
--
Newsguy - Basic Accounts - $39.95 / year

 

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

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