2017-06-19 6 views
0

Ich brauche etwas Hilfe für Bilder zu bekommen. Ich benutze preg_match_all Funktion.Wie bekomme ich Bild mit preg_match_all

Quelle: <img alt="test" title="test" src="/data/brands/test.png">

wie kann ich full image url bekommen?

Und das ist mein Code für Text. Ich muss hier ein Bild hinzufügen.

<? 
$link = 'link'; 
$marka = '@<div class="test">(.*?)</div>@si'; 
$getir = file_get_contents($link); 

preg_match_all($marka,$getir,$test1); 

$test = $test1[0]; 

echo $test[0]; ?> 

Danke.

Antwort

0

Dies könnte helfen Sie

$str = '<img alt="test" title="test" src="/data/brands/test.png">'; 

$regex = '#src="(.+?)">#'; 

preg_match($regex,$str,$match); 

echo $match[1]; 

//prints: /data/brands/test.png 
+0

Dies ist zumindest ein Syntaxfehler –

+0

Next - es 'src' von' '