Salve a tutti
ho questo codice che visualizza dei reminder della data corrrente presi dal calendario
quello che vorrei ottenere e' visualizare l'url (se presente) nella porzione di foreach, il campo e' detail
ho provato varie combinazioni ma l'url viene estratto fuori dalla class bootstrap
Codice PHP:
<ul class="h6 list-group">
<li class="h6 list-group-item bg-info text-white">
<?php
foreach ($dbo->query($sql) as $row) {
echo '<br>' . "$row[date]: $row[detail]" .'<br>-------';
}
?>
</li>
<ul>
questo codice estrae l'url o gli url se presenti
Codice PHP:
<?php
$txt = $row[detail];
$holder = explode("http",$txt);
for($i = 1; $i < (count($holder));$i++) {
if (substr($holder[$i-1],-6) != 'href="') { // this means that the link is not alread in an a tag.
if (strpos($holder[$i]," ")!==false) //if the link is not the last item in the text block, stop at the first space
$href = substr($holder[$i],0,strpos($holder[$i]," "));
else //else it is the last item, take it
$href = $holder[$i];
if (ctype_punct(substr($holder[$i-1],strlen($holder[$i-1])-1)) && ctype_punct(substr($holder[$i],strlen($holder[$i])-1)))
$href = substr($href,0,-1); //if both the fron and back of the link are encapsulated in punctuation, truncate the link by one
$holder[$i] = implode("$href\" target=\"_blank\" class=\"link\">http$href</a>",explode($href,$holder[$i]));
$holder[$i-1] .= "<a href=\"";
}
}
$txt = implode("http",$holder);
echo $txt;
?>