Possible Duplicate:
Get content between two strings PHP
Ok, here is my delima:
here is an example of my $content :
<!--nextpage-->First Title Here<!--nexttitle-->
some more text here
and here and here and here
a little more here!
<!--nextpage-->Second Title Here<!--nexttitle-->
some more text here
and here and here and here
a little more here!
<!--nextpage-->Th开发者_如何学Pythonird Title Here<!--nexttitle-->
some more text here
and here and here and here
a little more here!
How could I run a function that finds all "get_all_strings_between()" and echo them at the top of the $content:
**First Title Here** / **Second Title Here** / **Third Title Here**
and then my content HERE!
THanks!!
If I understood your question correctly this regexp will do it:
function get_all_strings_between($content) {
preg_match_all('/<!--nextpage-->([^<]*)<!--nexttitle-->/', $content, $m);
return implode(' / ', $m[1]);
}
// then you echo get_all_strings_between($content) where you need it
If I'm incorrect, please provide more info what are these nextpage
and nexttitle
tags? Are they appear like this literally?
精彩评论