我想添加"已售出"在那" /待售房屋细节/"网址。
所以它看起来像这样,需要去这个链接。 http://localhost/myhouse/homes-for-sale-sold-details/6200-SAN-VICENTE-BOULEVARD-LOS-ANGELES-CA-90048/OC16023911/306/
网址的一部分将与"出售"字: /舍出售出售的明细/
答案 0 :(得分:2)
// store url in variable
url = 'http://localhost/myhouse/homes-for-sale-details/6200-SAN-VICENTE-BOULEVARD-LOS-ANGELES-CA-90048/OC16023911/306/';
// get url with replace
new_url = url.replace("homes-for-sale-details", "homes-for-sale-sold-details");
答案 1 :(得分:0)
// store url in variable
$url = 'http://localhost/myhouse/homes-for-sale-details/6200-SAN-VICENTE-BOULEVARD-LOS-ANGELES-CA-90048/OC16023911/306/';
echo str_replace("homes-for-sale-details","homes-for-sale-sold-details",$url);
使用此代码即可。