0
Good afternoon! , I am using a php code to display news from a site, it turns out that I am also trying to display the image that has in it, however, I am not getting, the title and date of posting I am able to display normal, however, that I can not
<?php
// Mostrar Data na Tela.
$titulo = array();
$data = array();
$link = array();
$quantos = 0;
$exibir = 1;
$limite_title = 100;
foreach(simplexml_load_file("http://cidades.gov.br/ultimas-noticias?format=feed&type=rss")->channel->item as $item)
{
$imagem[] = $item->src;
$titulo[] = utf8_decode(substr($item->title, 0, $limite_title)."...");
$link[] = $item->link;
$data[] = utf8_decode($item->pubDate);
$quantos++;
}
for($i = $quantos-($exibir+1); $i < $quantos-1; $i++)
{
if($titulo[$i]!="")
{
echo
'
<li>
<figure><img src="'.$imagem[$i].'"></figure>
<a href="'.$link[$i].'" target="_blank" title="Leia mais clicando aqui!">'.utf8_encode($titulo[$i]).'
<small style="font-size:11px;color:#999;"><br/></a>'.str_replace(" ", " as ", date('d/m/Y H:m:s', strtotime($data[$i]))).'</small>
</li>
';
}
}
?>
What I did wrong ?
$item->src exists?
– Kaio Cesar
$image[] = $item->src;
– José Júnior
Navigate to the Description node and get the img tag, then you assign $image[]
– Kaio Cesar
I don’t understand, can you explain ?
– José Júnior
I put together a script and I don’t know if that’s what you want, see this link http://kithomepage.com/sos/abrepagina.php. Of course it’s not HTML formatted.
– user60252
I also developed one that brings everything. velja http://kithomepage.com/sos/abrepaginaFull.php
– user60252
Hello, Leo can forward me this script ? exactly the one I want the image
– José Júnior