Jump to content

Sorting results


fusionxn1

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/31036-sorting-results/
Share on other sites

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"
Link to comment
https://forums.phpfreaks.com/topic/31036-sorting-results/#findComment-143236
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/31036-sorting-results/#findComment-143239
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.