$path=http://AAA/AAA.jpg
想把上头的名字改为
$path=http://AAA/AAA_100x100.jpg
请问用php的话,要怎么写这行代码啊?
其中http://AAA/AAA.jpg是个变量得出的结果~
echo $path= substr($path,0,(strlen($path)-4)).'_100x100.jpg';
或者
echo $path= substr($path,0,(strlen($path)-4)).'_100x100'.substr($path,-4);
<?php
$path="http://AAA/AAA.jpg";
echo strtr($path,".","_100x100.");//将原地址中的“.”替换成“_100x100.”
?>
因为是个网址,所以里面有很多"."
echo strtr($path,".jpg","_100x100.jpg");//将原地址中的“.”替换成“_100x100.”
我这样换了后,发现里面所有的.都被替换了,请问有解决方法么?谢谢~
$path = preg_replace('/AAA.jpg/', 'AAA_100x100.jpg', $path) 已测试 可用