io utilizzo PHP 5.6, il tuo esempio e con il 7,comunque adattando con il tuo codice ricevo errori
Codice PHP:
<?php
$haystack3 = $row->websites;
preg_match_all('#^<span class=\'descr\'>(.*?)</span>$#m', $haystack3, $matches3);
$data3 = explode(',', $matches3[1]);
$data3 = array_filter(array_unique(array_map('trim', $data3)));
natsort($data3);
echo '<b>' . join(', ' , $data3 ) . '</b>';
echo "<br>\n";
echo '<font color="blue">' . '<b>' . count( $data3 ) . '</b>' . '</font>' . " tags were found." . '<br>';
var_dump(urlencode($matches3[1]));
?>
Warning: explode() expects parameter 2 to be string, array given in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 202
Warning: array_map(): Argument #2 should be an array in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 203
Warning: array_unique() expects parameter 1 to be array, null given in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 203
Warning: array_filter() expects parameter 1 to be array, null given in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 203
Warning: natsort() expects parameter 1 to be array, null given in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 204
Warning: join(): Invalid arguments passed in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 205
0 tags were found.
Warning: urlencode() expects parameter 1 to be string, array given in E:\OpenServer\domains\cinema\parsing\parsing_view2 .php on line 210
NULL
o anche cambiato il parametro 2 su $matches3[1]), niente errori, ma il risultato e' nullo
ecco la pagina estratta, come vedi il testo e' racchiuso tra <span class='descr'> e </span>
Codice HTML:
<li class="mt-1 mt-md-0">
<a target="_blank" class="websiteLink" rel="nofollow noopener" href="/out/website/6394-network1.com/">web 1</a>
<a title="website /sets overview" class="internalWebsiteLink" href="/websites/6394/network1.com/">i</a>
<span> <span class='alias'>Alex</span> <span class='descr'>test, test2, test3</span></span>
<a class="editLogo" title="edit" id="id8f9" href="#">✎</a>
<div id="id905" style="display:none">
<div id="id906" hidden="" data-wicket-placeholder=""></div>
</div>
</li>
<li class="mt-1 mt-md-0">
<a target="_blank" class="websiteLink" rel="nofollow noopener" href="/out/website/2488-network2.com/">web 2</a>
<a title="website /sets overview" class="internalWebsiteLink" href="/websites/2488/network2.com/">i</a>
<span> <span class='alias'>Alex 2</span> <span class='descr'>test, test2, test3, test4</span></span>
<a class="editLogo" title="edit" id="id8fa" href="#">✎</a>
<div id="id907" style="display:none">
<div id="id908" hidden="" data-wicket-placeholder=""></div>
</div>
</li>
<li class="mt-1 mt-md-0">
<a target="_blank" class="websiteLink" rel="nofollow noopener" href="/out/website/2489-network3.com/">web 3</a>
<a title="website /sets overview" class="internalWebsiteLink" href="/websites/2488/network3.com/">i</a>
<span> <span class='alias'>Alex 3</span> <span class='descr'>test</span></span>
<a class="editLogo" title="edit" id="id8fa" href="#">✎</a>
<div id="id907" style="display:none">
<div id="id908" hidden="" data-wicket-placeholder=""></div>
</div>
</li>
</li>
<li class="mt-1 mt-md-0">
<a target="_blank" class="websiteLink" rel="nofollow noopener" href="/out/website/2490-network4.com/">web 3</a>
<a title="website /sets overview" class="internalWebsiteLink" href="/websites/2488/network4.com/">i</a>
<span> <span class='alias'>Alex 4</span> <span class='descr'>test4 test5</span></span>
<a class="editLogo" title="edit" id="id8fa" href="#">✎</a>
<div id="id907" style="display:none">
<div id="id908" hidden="" data-wicket-placeholder=""></div>
</div>
</li>
mistero