SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Rome
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    working with a string and array

    Hi!

    on $string I have this data

    name1 (fsdfsdfsdf)<br>
    name2 (fwerwerew)<br>
    name3 (wtrjkl324)<br>

    I need to extract only

    name1
    name2
    name3

    Anyone can help me ?

    Thank you

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do you mean it is:
    PHP Code:
    $string="name1 (fsdfsdfsdf)<br>
    name2 (fwerwerew)<br>
    name3 (wtrjkl324)<br>"

    If so, then:
    PHP Code:
    $string="name1 (fsdfsdfsdf)<br>
    name2 (fwerwerew)<br>
    name3 (wtrjkl324)<br>"
    ;

    preg_match_all("/\w+ /",$string,$matches);

    print_r($matches); 
    Saul


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
  •