|
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]
|