1. 程式人生 > >PHP-正則 獲取該類字串小括號內字元

PHP-正則 獲取該類字串小括號內字元

$str = 'kk({"code":0,"msg":"操作成功","data":[{"name":Dave,"age":"25"}]})';

$rule='/(?:\()(.*)(?:\))/i';

preg_march_all($rule,$str,$res);

var_dump($res[1][0]);

輸出:

string(64) "{"code":0,"msg":"操作成功","data":[{"name":song,"age":"25"}]}"