簡體   English   中英

將對象字符串轉換為php中的數組

[英]Convert object string to array in php

我得到了這樣的對象字符串

字符串(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);           
} 

試試看:

$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);           
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM