0

I have data like this one inserted into database:

< p > < img style="float: left; margin: 5px;" title="Hollande et Ayrault veulent doper une reprise poussive src="http://static.ladepeche.fr/content/media/image/350/2013/12/21/201312212114-full.jpg" alt="Hollande et Ayrault veulent doper une reprise poussive»" width="350" > height="290" /> < / p >

< hr />

< h2 class="titre">< span style="font-size: 14pt; font-family: arial, helvetica, sans- serif;" >Ce que prevoit blah blah < / span >< / h2 >

< p> < span style="font-size: 12pt; font-family: arial, helvetica, sans-serif;" > Pour l’année prochaine, l’Insee prévoit une hausse du PIB de 0,2 % au premier ainsi qu’au deuxième trimestre, portant l’acquis de croissance à +0,7 % à fin juin 2014. L’Institut a annoncé que si le PIB grignotait +0,2 % chaque trimestre, «on arriverait à +0,9 % en moyenne annuelle pour 2014». C’est l’hypothèse retenue par le gouvernement > dans son budget. Le pouvoir d’achat des Français devrait augmenter de 0,5 % > sur l’ensemble de l’année 2013, ainsi que sur le premier semestre 2014. En 2012, il avait reculé de 0,9 %.< / span>< / p>

How can i retrieve only the image from this text using php?

The code I used but it doesnt work since the text contains html tags:

$imagetype = array('jpeg','png','jpg','gif');
$ext       = strtolower(substr(strrchr($articles->content_article, '.'), 1));

if(in_array($ext, $imagetype)){
    echo "<img src='".$articles->content_article."' width='450' height='250'>";
}
facemoi
  • 45
  • 1
  • 1
  • 5
  • I didn't understand the topic you gave me coz I'm just a newbie in php :\ – facemoi Dec 21 '13 at 16:18
  • is there any other easy way to do it? – facemoi Dec 21 '13 at 16:18
  • 2
    in other words: parse the HTML, pick the URL from the IMG tag, read in the data from that URL and put the result in to your Database. Regarding your last comment, to make a long story short: No. – Axel Amthor Dec 21 '13 at 16:47

0 Answers0