所以我的代碼在這裏:嵌套的PHP數組JSON
$featurecollection = ("FeatureCollection");
$test[] = array (
"type" => $featurecollection,
$features[] = array($images)
);
file_put_contents($cache,json_encode($test));
結果如下JSON:
[
{
"type":"feature",
"0":[
[
{
"title":"some title",
"src":"value",
"lat":"value",
"lon":"value"
},
{
"title":"some title",
...
但我需要的東西鳥巢不同,我是如何在PHP陣列上困惑應該被構造爲獲得如下結果:
{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"coordinates":[
-94.34885,
39.35757
],
"type":"Point"
},
"properties":{
"latitude":39.35757,
"title":"Kearney",
"id":919,
"description":"I REALLY need new #converse, lol. I've had these for three years. So #destroyed ! :(Oh well. Can't wait to get a new pair and put my #rainbow laces through. #gay #gaypride #bi #proud #pride #colors #shoes #allstar #supporting ",
"longitude":-94.34885,
"user":"trena1echo5",
"image":"http://images.instagram.com/media/2011/09/09/ddeb9bb508c94f2b8ff848a2d2cd3ece_7.jpg",
"instagram_id":211443415
}
},
這個php數組看起來像什麼?我被一切都嵌套但仍然有一個關鍵價值的方式拋棄。
我*想*您只需要更換'$功能[] =數組($圖片)'和' '特點'=>陣列($圖片)',不過我'm pretty n00b w/PHP ... – 2012-04-15 19:25:45