msing Posted August 1, 2009 Share Posted August 1, 2009 Hi, I'm looking to make a simple image gallery script. Displaying the images and other info is not a problem, but I'm looking to gather the names of the images from a list that is hosted on a different server. For example the list is located at http://www.site1.com/list.txt and is a simple one-name-per-line list of image names. The gallery script is located at http://www.site2.com/gallery.php and reads each image name from the list, and displays the appropriate images (which are hosted at site2). What would be the easiest way to do this? Basically, in summary I need to stick strings from a remotely-hosted txt file into an array. I know I could simply ftp or wget the file and the read from it, but I was hoping to avoid worrying about the permissions and whatnot of dealing with actual files. Thanks == Matt Link to comment https://forums.phpfreaks.com/topic/168429-retrieve-text-from-webpage-use-in-script/ Share on other sites More sharing options...
mattal999 Posted August 1, 2009 Share Posted August 1, 2009 Well, you could just use file_get_contents() on the list. Example: <?php $file = "http://www.site1.com/list.txt"; $images = array(); $list = file_get_contents($file); $list = explode("\n", $list); foreach($list as $image) { $images[] = $image; } ?> Link to comment https://forums.phpfreaks.com/topic/168429-retrieve-text-from-webpage-use-in-script/#findComment-888454 Share on other sites More sharing options...
msing Posted August 2, 2009 Author Share Posted August 2, 2009 Sounds like just what I need. Thanks. I knew it existed (pretty much anything you need already exists in php), but I wouldn't have known the function name. Link to comment https://forums.phpfreaks.com/topic/168429-retrieve-text-from-webpage-use-in-script/#findComment-889104 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.