Hypersource Posted September 24, 2013 Share Posted September 24, 2013 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;?> 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; } Link to comment https://forums.phpfreaks.com/topic/282398-glob-is-not-an-array/#findComment-1450970 Share on other sites More sharing options...
jazzman1 Posted September 24, 2013 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/>"; } 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. 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 Thanks @jazzman1 ; Your second answer worked like a charm. 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
Archived
This topic is now archived and is closed to further replies.