【发布时间】:2012-09-02 16:17:41
【问题描述】:
我有这个字符串:
"cursor:pointer; background:url(http://maps.google.com/staticmap?center=38.7376583333,-9.1658583333&maptype=satellite&zoom=14&size=300x300&key=ABQIAAAAvQ9c8pqKsi8K2dzb7UM9MhS13VDmd70a9rmDETSCgg2iXt3XnhQSnX4vFKfWO-3vdWNV5HHBnSLWLQ&sensor=true&hl=pt) no-repeat"
我想删除纬度和经度。所以我想把字符串的左边剪掉,直到"center=",然后从"&maptype="开始。
所以我已经剪掉了左边的部分,但现在我不知道如何剪掉右边的部分。
编辑:
$h1['style']=$html->find('td.sendGps',0)->style;
$string=$h1['style']; // i have this, which does not work like the $string=""cursor:pointer; background:url(http://maps.google.com/staticmap?center=38.7376583333,-9.1658583333&maptype=satellite&zoom=14&size=300x300&key=ABQIAAAAvQ9c8pqKsi8K2dzb7UM9MhS13VDmd70a9rmDETSCgg2iXt3XnhQSnX4vFKfWO-3vdWNV5HHBnSLWLQ&sensor=true&hl=pt) no-repeat""
$inicio = "?center=";
$fim = "&maptype=";
$b = substr($string, strpos($string, $inicio) + 8);
【问题讨论】:
-
用正则表达式不是更好吗?
-
查看
strrpos()。它与strpos()相同,但从字符串末尾开始搜索。 -
我把双引号留在了那里,但我认为您实际上并没有处理那些,对吧?
-
命题乔,你怎么了?