<?php
$folder = array(); // Creates a array for use later
foreach (glob("folder/*") as $thefolder) { // Use for each to go through and get each folder & file in the given directory
If (is_dir($thefolder)) { // We only want to get folders so we are making sure that we are adding a directory and not a file.
$folder[] = $thefolder; // Adds the file to the array created
}
}
echo $folder[0]; // 0 for 1st dir, 1 for 2nd and so on...
?>
$location = "/....../folder/";
echo basename("folder/My folder"); //outputs My folder
$folder = array();
foreach (glob("$location*") as $thefolder) {
If (is_dir($thefolder)) {
$folder[] = $thefolder;
$folderx = str_replace(' ', '.', basename($folder[0]));
}
}
foreach (glob("$location*") as $thefolder) {
If (is_dir($thefolder)) {
$folderx = str_replace(' ', '.', basename($thefolder));
rename($thefolder, str_replace(' ', '.', $thefolder);
break; // Breaks next loops since we only need 1
}
}
foreach (glob("$location*") as $thefolder) {
if (is_dir($thefolder)) {
$folderx=str_replace(' ', '.', $thefolder)
rename($thefolder, $folderx);
break; // Breaks next loops since we only need 1
}
}
echo $folderx;