fusionxn1 Posted December 18, 2006 Share Posted December 18, 2006 I have a script that fetches five images, after I figured out for to strip all of the crap out of it I am now left with the result of 5 URLs with a space in between each one.How can I make it that before the Space it adds the next url to another variable?I will tell you what I am trying to do:I am grabbing 5 images based on search results and I want to include all 5 into a generated image BUT as I said it is returning the 5 urls will spaces and I need them to be separate to work.Thanks. Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 Post the relevent code. Quote Link to comment Share on other sites More sharing options...
chiprivers Posted December 18, 2006 Share Posted December 18, 2006 If I follow what you are asking your are left with a string like this:$string = "www.domain.co.uk/image.gif www.domain.co.uk/another.gif www.domain.co.uk/im.gif";you can put these into an array like this:$images = explode(' ',$string);you then have:$images[0] = "www.domain.co.uk/image.gif"$images[1] = "www.domain.co.uk/another.gif"$images[2] = "www.domain.co.uk/im.gif" Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 EDIT TO NEW REPLY: Ill try that :) Ill reply later thanks :).Ok:Basically the variable in this code returns the results and my code is a little messy right now but this is the code that returns the url after filtering the crap:[code]preg_replace( array('/title="(.+?)"/','/alt="(.+?)"/','/height="(.+?)"/','/width="(.+?)"/','/<a href="(.+?)"/','</a>','/<img/','/" \/>/','/</','/>/'), array('','','','','','','','','',''), $file[8]);[/code]And What I get with that is:[code]http://imgurl.com/1.jpg http://imgurl.com/2.jpg http://imgurl.com/3.jpg http://imgurl.com/4.jpg http://imgurl.com/5.jpg[/code]Now I some how what to make all 5 separate (maybe into variables?) so I can include each one into a generated image. Right now im getting an error obviously because its trying to add an image to a generated one with all 5 urls and spaces.Hope someone can help me. Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 Ok to a limit yours works :)$images = explode(' ',$imagesreturn);to test it what i did wasecho $images[0];echo $images[1];But only one is showing. Hmm.. Any help? :). Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 Post the relevent code. Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 Thank you os much!I changed $images = explode(' ',$string); to $images = explode(' ',$string);and it works! Is it ok to go ahead and ask my last question?When someone links to the image say myimage.pngHow can I make it update everytime its accessed? Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 What do you mean by update? Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 Basically. The image is generated and saved.If I want to us eit on webpages and the information it saves to the png has changed it updates. Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 You would need to store the infomation in a text file or preferably db, then compare the new data with the old. If its different, regenerate the image. Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 I have no idea on how to do that :(. Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 Well you use a combination of [url=http://php.net/fopen]fopen[/url] and [url=http://php.net/fwrite]fwrite[/url], to write to a file.Post your code and we might be able to impliment an example. Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 Well when the image is generated it makes a cache file the first time but what I want do is the generated file is saved to a folder. When ever that file is accessed (the file is png) i want it to regenerate. Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 You have no way of knowing when the file is accessed. Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 Is it posible to make a php script have the extention of .png because i know some sites block the dynamic images? Quote Link to comment Share on other sites More sharing options...
fusionxn1 Posted December 18, 2006 Author Share Posted December 18, 2006 Anyone? :). Quote Link to comment 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.