am using readdir to get all the image from the folder like
function get_user_image($valid_user){
$rootdir = "../../../user/".$valid_user;
$dir = opendir("../../../user/".$valid_user);
$image = array();
scan_image($image,$rootdir);
print_r($image);
}
function scan_image($arr,$root){
$dir = opendir($root);
while (false!=($file=readdir($dir))){
if($file!='.'&&$file!='..'){
$isfile = strripos($file, ".");
if($isfile)
{
$filetype = substr($file,$isfile+1);
if($filetype=="jpg")
{
//echo $file."</br>";
array_push($arr, $file);
echo sizeof($arr)."</br>";
}
}
else
{
$curpath = $root."/".$file;
scan_image($arr,$curpath);
}
}
}
}
but the print_r($image) is empty,however,the echo sizeof($arr) is right, any idea why?