I'm trying to trim the end of a string starting from a specific tag like in the examle listed below and I'm stuck. Any help would be greatly appreciated.
This is the what the text looks like without the trim.
Here is the sample <!--more--> I don't want this to display.
This is what I want to display
Here is the sample
so basically trim everything from <!--more--> to the end.
Php trim() problem
Moderator: General Moderators
Re: Php trim() problem
Code: Select all
$string = reset(explode('<!--more-->', $string));Re: Php trim() problem
Thanks man. That worked like a charm.
Cheers,
Cheers,
Re: Php trim() problem
More code, but it might be faster, and I think more obvious (which is useful if you ever revisit this code again):
Code: Select all
$string = substr($string,0,strpos('<!--more-->')-1);Real programmers don't comment their code. If it was hard to write, it should be hard to understand.