-
SitePoint Enthusiast
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.
-
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks