find complete image path in php? -
i have serialized string :
now want find image information string , store in variable. can find image path , prints below code
$doc = new domdocument(); $doc->loadhtml($stry); $xpath = new domxpath($doc); $src = $xpath->evaluate("string(//img/@src)"); echo $src;
but want print complete img
tag atrributes height , width etc in below form :
$a = "<img src=\"http://www.techveze.com/wp-content/uploads/2013/11/router.jpg\" alt=\"\" width=\"345\" height=\"120\" class=\"aligncenter size-full wp-image-1884\" />" ;
anyone plz me...??
thanx.
you need unserialize string. return array. image stored in index image
.
// unserialize string , turn array $array = unserialize($str); $a = $array['image']; // give image enclosing `<a>` tag // create document html snippet $doc = new domdocument(); $doc->loadhtml($a); // obtain image tag $img = $doc->getelementsbytagname('img')->item(0); // save string $img_string = $doc->savehtml($img);
if want display string in html page, mean string not image(!), use htmlentities()
:
// echo <img> string(!) on html page echo htmlentities($img_string);
Comments
Post a Comment