Jeffro Posted April 29, 2011 Share Posted April 29, 2011 I have several lines of text formatted as such: title text – some more text blah blah blah How do I delete everything after title text from every line ( the and ndash and after)? Thanks! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 29, 2011 Share Posted April 29, 2011 Is the format always the same, with the literal '–' in it? $str = "[text to keep] –' [text to remove]"; $new = trim(substr($str, 0, strpos($str, '–'))); echo $new; // returns "[text to keep]" Quote Link to comment Share on other sites More sharing options...
Jeffro Posted April 29, 2011 Author Share Posted April 29, 2011 Is the format always the same, with the literal '–' in it? $str = "[text to keep] –' [text to remove]"; $new = trim(substr($str, 0, strpos($str, '–'))); echo $new; // returns "[text to keep]" Many thanks. Worked perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.