donglu9134 2015-06-21 11:05
浏览 338
已采纳

PHP数组中的大括号

I want to build this JS to a PHP array:

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'

I tried normal PHP array with JSON_ENCODE and PRETTY PRINT, but I dont know how to show the 'position' part inside an array.

Could you please help me?

Thanks in advance,

Tibor

  • 写回答

1条回答 默认 最新

  • dounan9070 2015-06-21 11:24
    关注

    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'
    ]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab基于鲸鱼算法优化vmd
  • ¥20 PCB设计与制作问答
  • ¥20 课堂跑如何下载ppt
  • ¥15 有没有哥看着画下电路
  • ¥15 STM32阿里云平台显示不了传感器采集的数据
  • ¥20 三菱FX系列PLC上位机串口下指令置位M64和M65,这两条指令分别是什么呢?
  • ¥15 有关结冰模拟程序咨询
  • ¥15 ubuntu服务器配置dns域名后无法访问其他域名
  • ¥50 本人复制了一个关于股票指标的代码,但是运行失败,有没有人帮我解决一下
  • ¥50 用matlab和numeca做透平机械流体力学和热力学模拟 价格可议