Skip to content

Commit c559ae1

Browse files
committed
ltrim 不支持中文,改为 mb_ 系列函数
1 parent 1941bfe commit c559ae1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/IpLocation.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,12 @@ private function getAddr($ip)
267267

268268
//没有省份标志 只能替换
269269
$_tmp_city = str_replace($location['province'], '', $location['country']);
270-
$_tmp_city = ltrim($_tmp_city, $seperator_shi); //防止直辖市捣乱 上海市xxx区 =》 市xx区
270+
271+
//防止直辖市捣乱 上海市xxx区 =》 市xx区
272+
$_tmp_shi_pos = mb_stripos($_tmp_city, $seperator_shi);
273+
if ($_tmp_shi_pos === 0) {
274+
$_tmp_city = mb_substr($_tmp_city, 1);
275+
}
271276

272277
//内蒙古 类型的 获取市县信息
273278
if (strpos($_tmp_city, $seperator_shi) !== false) {

0 commit comments

Comments
 (0)