title: How to split text based on two strings as one delimiter (for instance asterisks AND new line special character) using PHP?
body: <p>Can you help me split a long text based on the <strong>&quot;AND&quot;</strong> logical expression, for a delimiter made of both six asterisks AND a new line special character?</p>
  <p>I am new to PHP and doing my internship, and I have to fix a legacy issue.</p>
  <p>The two delimiters are each special characters, requiring an escape function according to my basic knowledge.</p>
  <p><strong>This is my data structure.</strong> <br />
  <br />First chunk doesn't start with any delimiter.
  <br />******
  <br />Second chunk is separated from the first one by six asterisks plus a carriage return.
  <br />******
  <br />Third chunk is separated from the second one by six asterisks plus a carriage return.
  <br />******
  <br />And son on... and on.
  <br />******
  <br />But we might find other asterisks, maybe six like ****** inside the paragraph, and those one are not to be split.</p>
  <p>Same for new lines without ****** which should stay the same.</p>
  <p><br />******
  <br />Also note that the number of chunks is variable in my data source. And I know this is a problem with a stinky structure, but the benefit of storing combine chunks was studied, and chosen to save storing space and time. I heard that such a model sucks, but we need to deal with some legacy.</p>
  <p><strong>This is what I would like to get, as a result.</strong> <br />
  Chunk 1:
  First chunk doesn't start with any delimiter.</p>
  <p>Chunk 2:
  Second chunk is separated from the first one by six asterisks plus a carriage return.</p>
  <p>Chunk 3:
  Third chunk is separated from the second one by six asterisks plus a carriage return.</p>
  <p>Chunk 4:
  And son on... and on.</p>
  <p>Chunk 5:
  But we might find other asterisks, maybe six like ****** inside the paragraph, and those one are not to be split.</p>
  <p>Same for new lines without ****** which should stay the same.</p>
  <p><br /><strong>This is the code I am using after adapting the explodeEscaped function found on the Internet.</strong> <br /></p>
  <p><code>print_r(explodeEscaped('***', $my_text_variable, '\n'));</code></p>
  <br />
  This function has been discussed on this platform, at [https://stackoverflow.com/questions/8519793/php-explode-but-ignore-escaped-delimiter][1].
  <p><br /><strong>This is the result I get from the code.</strong></p>
  <p><br />First chunk doesn't start with any delimiter.
  <br /><a href="https://stackoverflow.com/questions/8519793/php-explode-but-ignore-escaped-delimiter">1</a> =&gt; [2] =&gt;
  Second chunk is separated from the first one by six asterisks plus a carriage return.
  <br />[3] =&gt; [4] =&gt;
  Third chunk is separated from the second one by six asterisks plus a carriage return.<br />
  [5] =&gt; [6] =&gt;
  And son on... and on.
  <br />[7] =&gt; [8] =&gt;
  But we might find other asterisks, maybe six like [9] =&gt; [10] =&gt; inside the paragraph, and those one are not to be split.</p>
  <p>Same for new lines without [11] =&gt; [12] =&gt; which should stay the same.</p>
  <p><br />[13] =&gt;
  Also note that the number of chunks is variable in my data source. And I know this is a problem with a stinky structure, but the benefit of storing combine chunks was studied, and chosen to save storing space and time.</p>