Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

dinamic array in a while loop

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

dinamic array in a while loop

Postby RickyD77 » Wed Oct 23, 2002 8:04 am

ok theres my code and i would like to put the image name in a array in the while loop but i dont know how thx

<html><body>
<?
$path = 'images/';
$counter=0;
$counterStart = 0 ;
$counterEnd = $counterStart + 16 ;
$img='';
$imgTotal=0;
$dir_handle = @opendir($path) or die("Unable to open $path");
while($file = readdir($dir_handle)) {
if (substr($file, -3) == 'gif') {
$imgTotal++;
$counter++ ;
if ($counter > $counterStart && $counter < $counterEnd) {
echo "$file<br>";
//$img=$file;
} }}
closedir($dir_handle);
?>

</body></html>
RickyD77
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Oct 23, 2002 5:54 am

Re: dinamic array in a while loop

Postby mjr » Fri Oct 25, 2002 10:02 am

use
<html><body>
<?
$path = 'images/';
$counter=0;
$counterStart = 0 ;
$counterEnd = $counterStart + 16 ;
$img='';
$imgTotal=0;
$dir_handle = @opendir($path) or die("Unable to open $path");
while($file = readdir($dir_handle)) {
if (substr($file, -3) == 'gif') {
$imgTotal++;
$counter++ ;
if ($counter > $counterStart && $counter < $counterEnd) {
$images[$counter]=$file;
//$img=$file;
} }}
closedir($dir_handle);

for($i=0;$i!=count($images);$i++){
echo "$file<br>";
}

?>

</body></html>
mjr
New php-forum User
New php-forum User
 
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron