duanpie4763 2017-03-04 06:10
浏览 18
已采纳

在php中发出解码ajax帖子的问题

I am trying to decode an array of objects that I made in javascript and sent to php however, I cant seem to decode it correctly. The array with an object looks like this: enter image description here

the php code that I am using to get the information is this:

$allInformation = $_POST['information'];

//this works
$user = $allInformation[count($allInformation)-2];
$num = $allInformation = [count($allInformation)-1];
//this doesnt work 
$array = var_dump(json_decode($allInformation));

The index of array 1 and 2 work just fine, however, I cant seem to decode index 0 which is the object. How may I go about this?

  • 写回答

1条回答 默认 最新

  • dqf98772 2017-03-06 18:09
    关注

    got it to work, the array to php which was JSON stringified was [{"user":"user","date":"03/17/2017"},"user",134997] and i did $update = json_decode($_POST['information']); and then looped it to get user and date as obejcts i.e. $update[$i]->date . thanks all

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了