-2 php regex string quotes parsing
我试图将以下字符串解析为数组.
$str = [0,"Victoria Station, Bus Station Stand",null,null,0,null,51.496169,-0.143633]
Run Code Online (Sandbox Code Playgroud)
我在用
$result = explode(',', $str);
Run Code Online (Sandbox Code Playgroud)
我正在得到这样的数组
Array ( [0] => [0 [1] => "Victoria Station [2] => Bus Station Stand" [3] => null [4] => null [5] => 0 [6] => null [7] => 51.496169 [8] => -0.143633] )
Run Code Online (Sandbox Code Playgroud)
但我需要"维多利亚站,汽车站站"作为阵列中的1项.我知道这可以用正则表达式来实现.但我是新手.非常感谢您的指导.
这看起来像json我尝试
$str = '[0,"Victoria Station, Bus Station Stand",null,null,0,null,51.496169,-0.143633]';
$json = json_decode($str, true);
echo "<pre>";
var_dump($json);
Run Code Online (Sandbox Code Playgroud)
产量
array
0 => int 0
1 => string 'Victoria Station, Bus Station Stand' (length=35)
2 => null
3 => null
4 => int 0
5 => null
6 => float 51.496169
7 => float -0.143633
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
488 次 |
| 最近记录: |