Wie bekomme ich Bildpfad im Textformat mit PHP?Wie bekomme ich Bildpfad im Textformat mit PHP?
Ich habe Textformat wie folgt aus:
<p><span style="\"background-color:" rgb(255,="" 255,="" 0);="" font-weight:="" bold;="" font-style:="" italic;="" text-decoration:="" underline;\"="">TEST</span> <img src="\"https://www.google.co.th/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\"" style="\"width:" 544px;\"=""> <span style="\"font-style:" italic;\"="">TEST<img src="\"https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png\"" style="\"width:" 200px;\"=""></span><br></p>
Mein Code ist:
<?php
$str='<p><span style="\"background-color:" rgb(255,="" 255,="" 0);="" font-weight:="" bold;="" font-style:="" italic;="" text-decoration:="" underline;\"="">TEST</span> <img src="\"https://www.google.co.th/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\"" style="\"width:" 544px;\"=""> <span style="\"font-style:" italic;\"="">TEST<img src="\"https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png\"" style="\"width:" 200px;\"=""></span><br></p>';
libxml_use_internal_errors(true);
$dom=new DOMDocument;
$dom->validateOnParse=false;
$dom->standalone=true;
$dom->strictErrorChecking=false;
$dom->recover=true;
$dom->formatOutput=false;
$dom->loadHTML($str);
libxml_clear_errors();
$xp=new DOMXPath($dom);
$col=$xp->query('//img');
$images=array();
foreach($col as $img) $images[]=$img->getAttribute('src');
echo $images[0];
?>
Wenn ich meinen Code testen, es zeigt:
\"https://www.google.co.th/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\"
ich wissen will, wie meinen Code ändern, um zu zeigen:
https://www.google.co.th/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
Teile dieses Textes wurden durch 'addslashes()' und dann 'htmlentities()' ausgeführt. – AbraCadaver
Mit anderen Worten: Warum ist dieses Stück HTML völlig verstümmelt und irgendwo zwischen Nicht-Was-Sie-Denken-Es-ist und absolut ungültig? – deceze