PHP 从用户消息(字符串)获取图像 url 不适用于preg_match_all


PHP Get image url from user message (string) doesn't work with preg_match_all

你能告诉我我做错了什么吗?它总是告诉我它是图像,即使它不是。

编辑:如果有图像链接,我需要获取图像的链接。

while ( $row = mysql_fetch_assoc( $result ) ){
$msg = "<div class='msg'>[" . $row["time"] . "] <b>" . $row["name"] . ":</b> " . $row["message"];
echo $msg;
    preg_match_all( "/(https?:'/'/'S+'.(?:jpg|png|gif))'s+/", $msg, $urls );
if ( $urls ){
    echo "ye, its image";
    }
}

没有我想象的那么难。

while ( $row = mysql_fetch_assoc( $result ) ){
$msg = "<div class='msg'>[" . $row["time"] . "] <b>" . $row["name"] . ":</b> " . $row["message"];
echo $msg;
    preg_match_all( "/(https?:'/'/'S+'.(?:jpg|png|gif))'s+/", $msg, $urls );
if ( $urls ){
    echo '<img src=".$urls.">';
    }
}
相关文章: