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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.