Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Count Coding help

     

chrissim

1:48 am on Mar 12, 2012 (gmt 0)

5+ Year Member



hi guys,

i need some help with my script function below as i have no idea how to count number of images and echo count increment for eg

1. image.jpg
2. image.jpg
3. and etc





function createDir($path = '.')
{
if ($handle = opendir($path))
{


$files_array = array();
while (false !== ($files_array[] = readdir($handle)));
array_pop($files_array);
sort($files_array, SORT_STRING);
foreach($files_array as $file)
{
if (is_dir($path.$file) && $file != '.' && $file !='..')
printSubDir($file, $path, $queue);
else if ($file != '.' && $file !='..')
$queue[] = $file;
}

printQueue($queue, $path);

}
}

function printQueue($queue, $path)
{
foreach ($queue as $file)
{
printFile($file, $path);
}
}

function printFile($file, $path)
{
echo "<a href=\"".$path.$file."\" target=\"new\">$file</a>

}

lostdreamer

8:46 am on Mar 12, 2012 (gmt 0)

5+ Year Member





function printQueue($queue, $path)
{
$i=1;
foreach ($queue as $file)
{
printFile($i, $file, $path);
$i++;
}
}


function printFile($num, $file, $path)
{
echo $num . ") <a href=\"".$path.$file."\" target=\"new\">$file</a>

}

chrissim

9:06 am on Mar 12, 2012 (gmt 0)

5+ Year Member




hi,

im getting Parse error: syntax error, unexpected T_INC

lostdreamer

9:17 am on Mar 12, 2012 (gmt 0)

5+ Year Member



Sorry,

I copy pasted your code without noticing that there was a cut-off


function printFile($num, $file, $path) {
echo $num . ") <a href=\"".$path.$file."\" target=\"new\">$file</a>\r\n";
}


That should probably do it
 

Featured Threads

Hot Threads This Week

Hot Threads This Month