PHP数组中的大括号

时间:2015-06-21 11:05:43

标签: php arrays json

我想将这个JS构建为PHP数组:

Set Nocount On;

If Object_Id('tempdb.dbo.#table') Is Not Null
Begin
    Drop Table #table;
End

Create Table #table
(
     Id         Int Primary Key
    ,Col1       Int
    ,RDate      Datetime
    ,Col2       Int
    ,RYear      Int
    ,Col3       Int
)

Insert Into #table Values
 (1,6066,'03/31/2015 0:00',1,2015,3610)
,(2,6066,'12/31/2014 0:00',4,2014,16868) 
,(3,6066,'09/30/2014 0:00',3,2014,10809)
,(4,6066,'06/30/2014 0:00',2,2014,6905)
,(5,6066,'03/31/2014 0:00',1,2014,3326)

Select   t.Col1
        ,Sum(t.Col3) As ColSum
From    #table As t With (Nolock)
Where   t.RDate In ('03/31/2015','12/31/2014')
Group By t.Col1

我尝试使用JSON_ENCODE和PRETTY PRINT的普通PHP数组,但我不知道如何显示'位置'数组内的部分。

你能帮我吗?

提前致谢,

蒂博尔

1 个答案:

答案 0 :(得分:0)

PHP> = 5.4

[
    'title' => 'Property',
    'image' => '1-1-thmb.png',
    'type' => 'For Sale',
    'price' => '$price',
    'address' => '$address',
    'bedrooms' => '$bedrooms',
    'bathrooms' => '$maxguests',
    'area' => '$area',
    'position' => [
        'lat' => '$lat',
        'lng' => '$lng'
    ],
    'markerIcon' => 'marker-green.png'
]