这是一个例子:
$array = "[[51.228697283276,0.45897198252166],[51.228697283276,0.59374016480853],[51.312903819352,0.59374016480853],[51.312903819352,0.45897198252166]]";
这是一个例子:
$array = "[[51.228697283276,0.45897198252166],[51.228697283276,0.59374016480853],[51.312903819352,0.59374016480853],[51.312903819352,0.45897198252166]]";
这看起来像 JSON。您可以使用json_decode()
它来解码它:
json_decode($array);
使用此代码将此字符串转换为数组
<?php
$string ="[[51.228697283276,0.45897198252166],[51.228697283276,0.59374016480853],[51.312903819352,0.59374016480853],[51.312903819352,0.45897198252166]]";
$array = explode(',',$string);
for($i=0;$i<count($array);$i++){
$array[$i] = trim($array[$i],'[[');
$array[$i] = trim($array[$i],']]');
}
echo '<pre>'; print_r($array); ?>