Note that there are some explanatory texts on larger screens.

plurals
  1. PODelete first and last lines from string
    text
    copied!<p>I have string named $post (for example) which contain data bellow. I want to remove lines until first "TEXT" (I don't know how many tags will there be so no exact lines are possible). I also want to remove all lines bellow last "TEXT". </p> <pre><code>&lt;div id="content"&gt; &lt;div class="date"&gt;2013-02-11 16:19:57&lt;/div&gt; &lt;h2 class="storytitle"&gt;&lt;a href="p.php?slug=SOMESLUG"&gt;PRPHAHAHAH&lt;/a&gt;&lt;/h2&gt; &lt;!-- TAGS --&gt; &lt;div class="tags"&gt;&lt;a href="/tag/"&gt;slug1&lt;/a&gt; &lt;a href="/tag/"&gt;slug2&lt;/a&gt; &lt;a href="/tag/"&gt;slug3&lt;/a&gt; &lt;/div&gt;TEXT&lt;br /&gt; TEXT&lt;br /&gt; TEXT&lt;br /&gt; TEXT&lt;br /&gt; TEXT&lt;br /&gt; &lt;br /&gt; &lt;pre&gt;&lt;code&gt;1 2 3 4 5 &lt;/code&gt;&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt; TEXT &lt;p id="comments" class="separator-story"&gt; &lt;!-- &lt;div class="comments"&gt;&lt;/a href="/post/Somepost" --&gt; &lt;/p&gt; &lt;/div&gt; </code></pre> <p>The only thing I want to have in my string is this:</p> <pre><code>TEXT&lt;br /&gt; TEXT&lt;br /&gt; TEXT&lt;br /&gt; TEXT&lt;br /&gt; TEXT&lt;br /&gt; &lt;br /&gt; &lt;pre&gt;&lt;code&gt;1 2 3 4 5 &lt;/code&gt;&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt; TEXT </code></pre> <p>Note: </p> <ul> <li>I don't know how many tags user will have, nor how many lines I have to remove from start, which at the end mean I don't know where first "TEXT" start. </li> <li>I don't know how huge post will be, nor from where do I start deleting. </li> <li>I only know that there are 5 lines at the end that I need them removed. I only know that tags finish with and last lines start with <li>I don't know what will be first letter/word of the text I need to extract (TEXT is just example)</li> </ul> <p>Reference:<br> <a href="http://php.net/explode" rel="nofollow">Explode (PHP)</a><br> <a href="http://php.net/array_slice" rel="nofollow">Array Slice (PHP)</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload