dongxian6715 2009-11-09 21:43
浏览 57
已采纳

PHP解释jQuery序列化数据

I have a form that is capturing data sent from a google LocalSearch API. The user has the ability to select a specific result, some or all results via a checkbox i'm injecting into the form with jQuery. The checkbox value looks something like this:

title=Emijean+Web+Design+and+Management&streetAddress=63+James+St.&city=Parry+Sound&region=ON

So if I had multiple checkboxes they would all contain similar data and the post value for checkboxes addToDb[] would be an array full of the above.

What's the best way for me capture this data with my php script? I can figure it out using foreach, explode, etc. but I'm sure there must be a way to unserialize a javascript string using PHP that's more efficient.

Any ideas on how I could get output similar to this:

array(
  [0] => array(
    title => "Emijean Web Design and Management"
    streetAddress => "63 James St."
    city => "Parry Sound"
    region => "ON"
  )
)

Thanks everybody.

  • 写回答

2条回答 默认 最新

  • doukuiqian9911 2009-11-09 21:47
    关注

    That's a querystring format - you can use parse_str():

     $values = array();
     parse_str($str, $values);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献