将对象字符串转换为php中的数组

时间:2018-07-27 05:43:14

标签: php jquery

我得到了这样的对象字符串

  

string(479)“ [对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象],[对象对象]“

从jquery,我想将其转换为数组以在forEach循环中打印。

jQuery代码在这里:

$('#goExel').on('click',function(){
    $.ajax({
        url:'<?=base_url()?>reports/report-show-wise/',
        type:'post',
        data:data,
        success:function(resp){
            var json_obj = JSON.parse(resp);
            console.log(json_obj.wo_no);
            window.location.href = "<?=base_url()?>reports/call-status-excel/"+btoa(json_obj);
        }
    });
});

我的php代码在这里:

$call_info = base64_decode($_call_info);
$data['payment_cheque'] =json_decode($_call_info,true);
var_dump($data); 
foreach ($call_info as $j => $res) {
    array_push($part_indent_name, $res->name);           
} 

1 个答案:

答案 0 :(得分:0)

尝试一下:

$call_info = base64_decode($_call_info);
$data['payment_cheque'] =json_decode($call_info,true);  // Variable was wrong here.
var_dump($data);

foreach ($data['payment_cheque'] as $j => $res) {  // Array variable changed here.
     array_push($part_indent_name, $res->name);           
}