PHP 中带有中文字符串的截取可以直接使用 substr
方法,无需使用 mb_substr
。
<?php
$s = '<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:queryTablesResponse xmlns:ns2="http://web.server.game.com/"><return>{"list":[{"bankerCloseBool":false,"chexuanStatus":"WAIT","clubid":0,"create":{"roomname":"用户5691的牌局","shengmangbeishu":2,"xiumangorzoumang":1}}]}</return></ns2:queryTablesResponse></S:Body></S:Envelope>';
$p1 = strpos($s, "<return>") + strlen("<return>");
$p2 = strpos($s, "</return>");
$sus = substr($s, $p1, $p2 - $p1);
echo $sus; // {"list":[{"bankerCloseBool":false,"chexuanStatus":"WAIT","clubid":0,"create":{"roomname":"用户5691的牌局","shengmangbeishu":2,"xiumangorzoumang":1}}]}
?>
标签:中文,p1,截取,substr,字符串,PHP
From: https://www.cnblogs.com/cyansill/p/18570031