Welcome Guest, Not a member yet? Register   Sign In
Pagebreak
#1

[eluser]Kemik[/eluser]
Hello all,

I'm coding a blog backend and want the homepage to only display the content up to the point where it finds a <!-- pagebreak --> You may recognise the comment, it's from a TinyMCE pagebreak.

I know how to find a string in content but I'm not sure how to make it stop when it finds it.

e.g.

Quote:Here is some text.

Blah Blah Blah
<!-- pagebreak -->
And some more

You wouldn't see "And some more".

Thanks.
#2

[eluser]Pascal Kriete[/eluser]
There are a few php options I can think of.
Code:
$whatever = explode("<!-- pagebreak -->", $full_string)[0];
$whatever = wordwrap($full_string, stripos($full_string, "<!-- pagebreak -->");

//If you're using php 6
$whatever = stristr($full_string, "<!-- pagebreak -->", TRUE);

Stupid haystack/needle string/array switcheroo.
#3

[eluser]Kemik[/eluser]
PHP 6? heh. My host has just upgraded to PHP 5.

Didn't think of exploding it. Good idea.
#4

[eluser]adamp1[/eluser]
I have to say I think the explode may be the best since then if you have multiple <!-- pagebreak --> needles. it will split them all up into an array field representing each page. Then when you use pagination you can pull the corresponding section out of the array. The other methods only allow you to have a single pagebreak and they never return the text after it.




Theme © iAndrew 2016 - Forum software by © MyBB