- var_export: documentation ( source)
- preg_split: documentation ( source)
<?php
$txt = <<<TXT
First chunk doesn't start with any delimiter.
******
Second chunk is separated from the first one by six asterisks plus a carriage return.
******
Third chunk is separated from the second one by six asterisks plus a carriage return.
******
And son on... and on.
******
But we might find other asterisks, maybe six like ****** inside the paragraph, and those one are not to be split.
Same for new lines without ****** which should stay the same.
TXT;
var_export(
preg_split('/\R*^\*{6}$\R*/m', $txt, 0, PREG_SPLIT_NO_EMPTY)
);