Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

iterate through all the elements in an array instead of print_r

<?php

$filesarray = array();

if ($handle = opendir('.')) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != ".." && is_file($entry)) {
            //echo "$entry<br />";
            $filesarray[] = $entry;
        }
    }
    closedir($handle);
}

print_r($filesarray);
?>

Open in new window


this question is just for the last line:
there are elements in

print_r($filesarray);

and I want to do a foreach or while loop to iterate through all the elements and echo each element
Avatar of Rahul Gupta
Rahul Gupta
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of sivagnanam chandrakanth
sivagnanam chandrakanth
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

$key=>value works
thank you