简体   繁体   中英

Add a <img src=*****><br> at the end of this regular expression

您好,如何在每次比赛的末尾添加<img src=*****><br> ,但没有数组,因为我将对结果进行编码?

preg_match_all('!http://.+\.(?:jpe?g|png|gif)!Ui', $content, $filtered);

Just concatenate the results and store them in an array:

$arr = array();
$arr[] = $filtered[0] . "<br/>";
if(preg_match_all('#http://[\S]+(?:jpe?g|png|gif)#is', $html, $matches)){
$i = 0;
foreach($matches[0] as $value){
    if(in_array($i, array(0, 3))) continue;
    $img .= '<img src="'.$value.'"><br>';
    $i++;
    }
}

echo $img;

Output (removed domain name by hand)

<img src="http://galerije/ford%20focus/qy974l.jpg"><br><img src="http://galerije/ford%20focus/m8zhh0.jpg"><br><img src="http://galerije/ford%20focus/ifpixx.jpg"><br><img src="http://galerije/ford%20focus/1zvzof8.jpg"><br><img src="http://galerije/ford%20focus/ir8cqv.jpg"><br><img src="http://galerije/ford%20focus/9vjtrd.jpg"><br><img src="http://galerije/ford%20focus/2m29p4j.jpg"><br><img src="http://galerije/ford%20focus/znm0yt.jpg"><br><img src="http://galerije/ford%20focus/2ln8l7t.jpg"><br><img src="http://galerije/ford%20focus/mta0ap.jpg"><br>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM