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 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行