NYCPHP Meetup

NYPHP.org

[nycphp-talk] foreach ERROR

CED Consult at CovenantEDesign.com
Wed Jul 19 22:04:32 EDT 2006


Awesome,  That was the issue, my script was fine, the $dir was amiss,
changed it to '../Music, and all is wonderful. Thanks to evceryone who
helped over the past few days.

Cheers
----- Original Message ----- 
From: "Flavio daCosta" <nyphp at n0p.net>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Wednesday, July 19, 2006 9:32 AM
Subject: Re: [nycphp-talk] foreach ERROR


I haven't been following along, so forgive me if this has been already
covered.  Looking at the error and the code, for one, I can see a
problem with the path.  You are in '.../Audio/mp3', what you want is
'../Music'.  Secondly, I'm not really sure what your objectives are, but
it appears that some simplification is in order.

Food for thought:

<?php
$dir    = '../Music';
$return = array ();
foreach (glob ("$dir/*.mp3") as $item)
{
    $return[] = basename ($item);
}
print_r($return) ;
?>


> From: "CED" <Consult at CovenantEDesign.com>
> This is the most recent, and stripped down, state:
>
> <?
> $dir = '../Audio/Music';
> foreach(glob("$dir/*.mp3") as $item){$sort[] = (end(explode('/',$item)));}
>     foreach($sort as $item){$return[]= $item;}
>      if(!$return){return array();}
>
>   echo($return[0]) ;
>   ?>
>
> And this is still the error:
>
> Warning: Invalid argument supplied for foreach() in
> /hsphere/local/home/skoilnog/edwardprevost.info/Audio/mp3/Audio.php on
line
> 4
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php






More information about the talk mailing list