www.webdeveloper.com
Results 1 to 3 of 3

Thread: Get string data between characters

  1. #1
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    363

    Question Get string data between characters

    I want to get information between two characters using PHP.

    For example, if I have the string:

    Tralala*42*lalala*wee*morewords

    I want to extract the characters between the first two * characters. Therefore, my variable will read "42".

    How would I go about doing this?

    Thanks,
    multi

  2. #2
    Join Date
    Apr 2010
    Posts
    227
    Hiya

    Explode is your friend.

    PHP Code:
    $string "Tralala*42*lalala*wee*morewords";
    $array explode("*",$string);


    echo 
    $array[0]; //Tralala
    echo $array[1]; //42 

  3. #3
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    363
    Then explode I shall use.
    I thank you for your time.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles