homepage Welcome to WebmasterWorld Guest from 54.237.54.83
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Count Coding help
chrissim




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

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




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



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




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


hi,

im getting Parse error: syntax error, unexpected T_INC

lostdreamer




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved