Hypersource Posted September 24, 2013 Share Posted September 24, 2013 (edited) Im working on an image slideshow, but glob() is not working. Here is my code: PHP Version: 5.3 <?php$dir = "http://www.harvester.tk/560/img/*.*";foreach (glob("$dir") as $filename) { echo $filename;?> Edited September 24, 2013 by Hypersource Quote Link to comment https://forums.phpfreaks.com/topic/282398-glob-is-not-an-array/ Share on other sites More sharing options...
jazzman1 Posted September 24, 2013 Share Posted September 24, 2013 Try, <?php $dir = __DIR__; foreach (glob($dir.'/'.'*.*') as $filename) { echo $filename; } Quote Link to comment https://forums.phpfreaks.com/topic/282398-glob-is-not-an-array/#findComment-1450970 Share on other sites More sharing options...
Solution jazzman1 Posted September 24, 2013 Solution Share Posted September 24, 2013 I'm not sure that a glob() supports the Hypertext Transfer Protocol (HTTP). Example2, if the searchable images are outside of the current directory: $dir = $_SERVER['DOCUMENT_ROOT'].'/'.'path_to_image_directory'; foreach (glob($dir.'/'.'*.*') as $filename) { echo "<a href=\"".$filename."\">".$filename."</a><br/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/282398-glob-is-not-an-array/#findComment-1450976 Share on other sites More sharing options...
vinny42 Posted September 24, 2013 Share Posted September 24, 2013 $dir = "http://www.harvester.tk/560/img/*.*"; You cannoty access a URL asif it is a directory on your local filesystem. Quote Link to comment https://forums.phpfreaks.com/topic/282398-glob-is-not-an-array/#findComment-1450986 Share on other sites More sharing options...
Hypersource Posted September 24, 2013 Author Share Posted September 24, 2013 (edited) Thanks @jazzman1 ; Your second answer worked like a charm. Edited September 24, 2013 by Hypersource Quote Link to comment https://forums.phpfreaks.com/topic/282398-glob-is-not-an-array/#findComment-1451028 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.