I have strings that looks like this:
John Miller-Doe - Name: jdoe
Jane Smith - Name: jsmith
Peter Piper - Name: ppiper
Bob Mackey-O'Donnell - Name: bmackeyodonnell
I’m trying to remove everything after the second hyphen, so that I’m left with:
John Miller-Doe
Jane Smith
Peter Piper
Bob Mackey-O'Donnell
So, basically, I’m trying to find a way to chop it off right before “- Name:”. I’ve been playing around with substr and preg_replace, but I can’t seem to get the results I’m hoping for… Can someone help?
Assuming that the strings will always have this format, one possibility is:
Reference:
substr,strpos