SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    Montreal, Canada
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with string manipulating

    Hi,

    I need your help with string manipulation. Here is what I need to do:

    Before the manipulation I have this:
    PHP Code:
    $var1 "The brown fox jumps over the fence. (It jumps? Yes, it jumps)" 
    After I want this:

    PHP Code:
    $var1 "The brown fox jumps over the fence"
    $var2 "It jumps! Yes, it jumps" 
    I guess I'll need regexp to do that, but I don't know much of regexp.

    Thanks,

    MD
    Dis donc, qu'est-ce qu'il dit ce mec? Hein? Je comprends rien...

  2. #2
    The short answer is yes... Herbster's Avatar
    Join Date
    Oct 2001
    Location
    Bay City, Oregon
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This can be tightened up, but I think the code will explain more than a couple paragraphs of prose. [img]images/smilies/wink.gif[/img]
    PHP Code:
    $start strpos($var1,"(" ) + 1;
    $end strpos($var1," )" );
    $var2 substr($var1,$start,($end $start));
    $start $start -1;
    $var1 substr($var1,0,$start); 
    I've about had it with this editor. It should be ")" not " )".
    OK. That didn't work... There shouldn't be a space in front of the ")" that is enclosed in double quotes.


Bookmarks

Posting Permissions

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