chdir() function fails with non ASCII folder name
I have the following problem: I need to go through all my sub folder and
for each sub folder do a certain task. my sub folder, which are located
under ../images/ folder have a non ASCII name (Hebrew). I was able to
extract the sub folder names and put them all in an array. When I'm
looping through the array, I'm trying the set the subfolder name using the
chdir() function, but it fails with: Warning: chdir() [function.chdir]: No
such file or directory (errno 2) in
/home/a2056935/public_html/android_connect/loopingDir.php on line 44.
The strange thing is that when I enter namually the subfolder name,
chdir("î÷åí2"), it works fine. But when I try to go through the prev.
created sub folder array, it fails.
Thank you all you your help.
there's my code: function GetSubFoldersArray(){ $subFoldersArr = array();
$yourStartingPath = "images";
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($yourStartingPath),
RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file) {
if($file->isDir()) {
$path = strtoupper($file->getRealpath());
$path2 = PHP_EOL;
$path3 = $path.$path2;
$result = end(explode('/', $path3));
array_push($subFoldersArr, $result);
}
}
return $subFoldersArr;
}
$subFolders = GetSubFoldersArray();
// $response["images_arr"] = array();
$arrlength=count($subFolders);
chdir("images");
for($x=0; $x<$arrlength; $x++)
{
echo $subFolders[$x];
echo "<br>";
echo getcwd();
echo "<br>";
chdir($subFolders[$x]);
}
No comments:
Post a Comment