Extracting GTIN (regex)
<p>I'm looking to extract GTIN codes from documents, they're 8, 12, 13 or 14 digit numbers. So I'm doing this:</p>

<pre><code>$html = '8 digit 12345678 and now 12 digit 123456789012';

$extractGTIN = '/\d{7}$|^\d{11}$|^\d{12}$|^\d{13}/mi'; 
preg_match_all($extractGTIN, $html, $barcodes);

echo print_r ($barcodes, 1);    
</code></pre>

<p>... but unexpectedly, it returns:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [0] =&gt; 6789012
        )

)
</code></pre>