Arranging output of opendir function by last modification?
Moderator: General Moderators
Sould i t look like this?
If so, it is returning this error:
Code: Select all
<?php
$arrayFiles=glob('*.*');
$date=date ("F d Y H:i:s.", filemtime($filename));
if($date){
foreach ($date as $filename) {
echo "$filename <br>";
}
}
else
echo"File not found."
?>Code: Select all
Warning: Invalid argument supplied for foreach() in /host/htdocs/vuns/index.php on line 5
Last edited by ozzy on Sun Apr 16, 2006 2:00 pm, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Come on dude you know you can do a little more reading aroundozzy wrote:Sould i t look like this?If so, it is returning this error:Code: Select all
<?php $arrayFiles=glob('*.*'); $date=date ("F d Y H:i:s.", filemtime($filename)); if($date){ foreach ($date as $filename) { echo "$filename <br>"; } } else echo"File not found." ?>Code: Select all
Warning: Invalid argument supplied for foreach() in /host/bluemicro.digibase.ca/htdocs/vuns/index.php on line 5
http://www.php.net/foreach
php.net is your friend (and my friend!).
foreach() is a speacial loop. It loops over an array. The basic structure is one of the two possible variations below:
Code: Select all
foreach ($some_array as $value)
{
//Look at each value in the array and tore it temporarily in $value
}
foreach ($some_array as $key => $value)
{
//In an array like:
// $some_array['foo'] = 'bar';
// Look at each key (foo) and each value (bar)
}As you may have noticed... we don't often just write out code for you... you learn far more struggling through it by yourself
I have looked through the foreach manual on php.net.. but i didnt fully understand it.
I also know what the problem is, but requests are of how to reslove them.
I also know what the problem is, but requests are of how to reslove them.
Code: Select all
Warning: Invalid argument supplied for foreach() in /host/htdocs/vuns/index.php on line 5- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: