Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default Seperating data with PHP

    I'm trying to figure out how to separate the id from a youtube url, however I can't use explode because after the id in the url there is nothing to explode.

    http://www.youtube.com/watch?v=Q4pY3QtiGyo

    I need to separate the bit in bold, however someone might imput an url like this-

    http://www.youtube.com/watch?v=Q4pY3QtiGyo&feature=rec-fresh

    Which would make exploding it even harder, any ideas?
    Lets set the stage on fire, and hollywood will be jealous.

  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php
    $str 
    "http://www.youtube.com/watch?v=Q4pY3QtiGyo&feature=rec-fresh";
    if(
    eregi("&",$str))
    {
    $str explode("v=",$str);
    $str explode("&",$str[1]);
    $str $str[0];
    }
    else
    {
    $str explode("v=",$str);
    $str $str[1];
    }
    ?>
    I think that should cover all cases
    Last edited by MrCraig; 14-09-2008 at 04:00 PM.
    Coming and going...
    Highers are getting the better of me

  3. #3
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Yeah, unfortunately that's the problem, the & sign isn't always there.
    Lets set the stage on fire, and hollywood will be jealous.

  4. #4
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Ye i just realised and edited post
    Coming and going...
    Highers are getting the better of me

  5. #5
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Thanks
    Lets set the stage on fire, and hollywood will be jealous.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •