scorplev Posted October 5, 2009 Share Posted October 5, 2009 $path = "images/gallery/"; $folders = opendir($path); while (($folder = readdir($folders)) !== false) { $foldersArray[] = $folder; } for($i=0;$i<sizeof($foldersArray);$i++) { echo "<a href=index.php?dir=$foldersArray[$i])>$foldersArray[$i]</a>"; } that works fine when folder name doesn't include spaces. But when a folder contains space the following output: <a href=index.php?dir=Name>Name Of Folder</a> and not: <a href=index.php?dir=Name Of Folder>Name Of Folder</a> Link to comment https://forums.phpfreaks.com/topic/176551-solved-myvar-that-includes-spaces-isnt-parsed-properly-with-_getmyvar/ Share on other sites More sharing options...
cags Posted October 5, 2009 Share Posted October 5, 2009 Theres a function called urlencode that will fix that for you. Just bare in mind you will probably need to use urldecode on the other end. <?php echo '<a href=index.php?dir="'. urlencode($foldersArray[$i]) . '">' . $foldersArray[$i] . '</a>'; ?> Link to comment https://forums.phpfreaks.com/topic/176551-solved-myvar-that-includes-spaces-isnt-parsed-properly-with-_getmyvar/#findComment-930677 Share on other sites More sharing options...
scorplev Posted October 5, 2009 Author Share Posted October 5, 2009 Thank you very much!!! that is exactly what I wanted! Link to comment https://forums.phpfreaks.com/topic/176551-solved-myvar-that-includes-spaces-isnt-parsed-properly-with-_getmyvar/#findComment-930726 Share on other sites More sharing options...
cags Posted October 5, 2009 Share Posted October 5, 2009 Excellent, glad it's fixed. Don't forget to mark the topic solved (button botom left). Link to comment https://forums.phpfreaks.com/topic/176551-solved-myvar-that-includes-spaces-isnt-parsed-properly-with-_getmyvar/#findComment-930728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.