SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Bobosse's Avatar
    Join Date
    Feb 2003
    Location
    California
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Erase or Ignore everything after sign?

    Hi guys,

    I have an expression that I need to clean up. It's pullled out from a feed and it's like this:

    field1,field2|field3,field4

    but it also can be:

    field1,field2,field3|field4

    or like this:

    field1|field2,field3,field4

    In either 3 cases, I want only everything before the "|" and forget this and the rest of the line...

    How to do this?

    Thanks for the help.

  2. #2
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    let's say all your stuff is in a string

    $string = "field1,field2|field3,field4";
    $arr = explode("|",$string);
    $the_thing_you_need = $arr[0];

    this should work.


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
  •