修改图像属性src

时间:2010-08-04 00:51:12

标签: php preg-replace

这就是我所拥有的

<img src="http://some.site.com/v/b/image-name/_thumb_100x100.jpg">

我正在尝试通过将大小替换为_thumb_200x200.jpg

来修改src

我尝试了preg_replace(),但没有。

2 个答案:

答案 0 :(得分:1)

假设您在字符串中包含该代码,则可以使用str_replace:

$str = str_replace('_thumb_100x100.jpg', '_thumb_200x200.jpg', $str);

答案 1 :(得分:1)

以下是使用preg_replace

的方法
$src="http://some.site.com/v/b/image-name/_thumb_100x100.jpg";

echo preg_replace('/_thumb_100x100.jpg/','_thumb_200x200.jpg',$src);
相关问题