Note that there are some explanatory texts on larger screens.

plurals
  1. POpreg_match_all into simple array
    text
    copied!<p>I have preg_match_all function:</p> <pre><code>preg_match_all('#&lt;h2&gt;(.*?)&lt;/h2&gt;#is', $source, $output, PREG_SET_ORDER); </code></pre> <p>It's working as intended, BUT the problem is, it preg_matches all items twice and into a huge multi dimensional array like this for example where it, as intended, preg_matched all 11 items needed, but twice and into a multidimensional array:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; &lt;h2&gt;10. &lt;em&gt;Cruel&lt;/em&gt; by St. Vincent&lt;/h2&gt; [1] =&gt; 10. &lt;em&gt;Cruel&lt;/em&gt; by St. Vincent ) [1] =&gt; Array ( [0] =&gt; &lt;h2&gt;9. &lt;em&gt;Robot Rock&lt;/em&gt; by Daft Punk&lt;/h2&gt; [1] =&gt; 9. &lt;em&gt;Robot Rock&lt;/em&gt; by Daft Punk ) [2] =&gt; Array ( [0] =&gt; &lt;h2&gt;8. &lt;em&gt;Seven Nation Army&lt;/em&gt; by the White Stripes&lt;/h2&gt; [1] =&gt; 8. &lt;em&gt;Seven Nation Army&lt;/em&gt; by the White Stripes ) [3] =&gt; Array ( [0] =&gt; &lt;h2&gt;7. &lt;em&gt;Do You Want To&lt;/em&gt; by Franz Ferdinand&lt;/h2&gt; [1] =&gt; 7. &lt;em&gt;Do You Want To&lt;/em&gt; by Franz Ferdinand ) [4] =&gt; Array ( [0] =&gt; &lt;h2&gt;6. &lt;em&gt;Teenage Dream&lt;/em&gt; by Katie Perry&lt;/h2&gt; [1] =&gt; 6. &lt;em&gt;Teenage Dream&lt;/em&gt; by Katie Perry ) [5] =&gt; Array ( [0] =&gt; &lt;h2&gt;5. &lt;em&gt;Crazy&lt;/em&gt; by Gnarls Barkley&lt;/h2&gt; [1] =&gt; 5. &lt;em&gt;Crazy&lt;/em&gt; by Gnarls Barkley ) [6] =&gt; Array ( [0] =&gt; &lt;h2&gt;4. &lt;em&gt;Kids&lt;/em&gt; by MGMT&lt;/h2&gt; [1] =&gt; 4. &lt;em&gt;Kids&lt;/em&gt; by MGMT ) [7] =&gt; Array ( [0] =&gt; &lt;h2&gt;3. &lt;em&gt;Bad Romance&lt;/em&gt; by Lady Gaga&lt;/h2&gt; [1] =&gt; 3. &lt;em&gt;Bad Romance&lt;/em&gt; by Lady Gaga ) [8] =&gt; Array ( [0] =&gt; &lt;h2&gt;2. &lt;em&gt;Pumped Up Kicks&lt;/em&gt; by Foster the People&lt;/h2&gt; [1] =&gt; 2. &lt;em&gt;Pumped Up Kicks&lt;/em&gt; by Foster the People ) [9] =&gt; Array ( [0] =&gt; &lt;h2&gt;1. &lt;em&gt;Paradise&lt;/em&gt; by Coldplay&lt;/h2&gt; [1] =&gt; 1. &lt;em&gt;Paradise&lt;/em&gt; by Coldplay ) [10] =&gt; Array ( [0] =&gt; &lt;h2&gt;Song That Get Stuck In Your Head YouTube Playlist&lt;/h2&gt; [1] =&gt; Song That Get Stuck In Your Head YouTube Playlist ) ) </code></pre> <p>How to convert this array into simple one and without those duplicated items? Thank you very much.</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