Results 1 to 4 of 4

Thread: Show all text after specific word in a string.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    Show all text after specific word in a string.

    Hi,

    I am trying to pull what ever text is after a certain part of a string. For example

    $string = "Radio that plays Justin Timberlake";

    I want it to display what ever text is after 'Radio that plays'

    I am trying to get it to grab the artist.


    Any ideas?



    (P.S the string will always be a different artist, above is just an example'

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Show all text after specific word in a string.

    Is "Radio that plays" constant? If so then you can use substr()

    PHP Code:

    $string 
    "Radio that plays Justin Timberlake";
    $artist substr($string17);
    // This will include everything after Position 17... 'Justin Timerberlake' 

  3. #3
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: Show all text after specific word in a string.

    You could also use the build in PHP function explode.

    http://us1.php.net/explode

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Show all text after specific word in a string.

    Explode wont work for this case... Explode required a delimiter... there is no usable delimiter in the text he provided.

Posting Permissions

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



Click Here to Expand Forum to Full Width