Trim a text after first occurence of a specified string
Posted on 2006-04-13
I use a function to get first 300 characters from the file. Then I display only 25 words from it.
$fd = fopen ($pathandfile, "r");
$content = fread ($fd, 300);
$content_array = explode (" ", $content)
$content_array = array_slice($content_array, 0, 24);
$content = implode(" ", $content_array);
Now, I want to find out if a string '<P> </P>' exist, and cut everything after the first instance of the string.
Note: '<P>' can also be typed lowercase '<p>';