6
我無法從angularjs中的php數組中獲取interview_docs數據。我試過很多JSON編碼選項,但它沒有woked out.How獲得在JS interview_docs數據這是我的數組:將php數組編碼爲js變量缺少一些數據?
Array(
[id] => 1
[tag] => 2
[title] => Test
[job_submission_id] => 0
[job_id] => 14
[candidate_id] => 55
[mail_to] => [email protected]
[cc_to] => [email protected]
[interviewer] => [email protected]
[interview_type] => 1
[interview_date] => 2017-10-04
[from_time] => 00:00:00
[to_time] => 01:00:00
[to_date] =>
[location] =>
[time_zone] => Asia/Kolkata
[status] => 1
[comments] => dwedfwef
[created_by] => 1
[modified_by] => 1
[created_at] => 2017-10-03 12:21:13
[updated_at] => 2017-10-03 12:21:13
[job_title] => Test
[candidate_name] => New t
[candidates] => Array
(
[id] => 55
[first_name] => New
[last_name] => t
)
[jobs] => Array
(
[id] => 14
[code] => 10
[title] => Test
)
[interview_docs] => Array
(
[0] => Array
(
[id] => 1
[interview_id] => 1
[unique_name] => 2017_10_roa2XKlIDc9gmzmO7TK37rsfuX3YRigqUxbvIYWe.txt
[name] => first.png
)
[1] => Array
(
[id] => 2
[interview_id] => 1
[unique_name] => 2017_10_6RaAm3MU5ZZ1x4l3q8VLYNhUkgvS3v2ljNZVizm1.png
[name] => Screenshot (15).png
)
)
)
當我這樣做: VAR數據= <?php echo json_encode($array); ?>;
控制檯。日誌(數據); 我得到這個
interview_docs:Array(0)
length:0
__proto__:Array(0)
我無法得到的PHP數組中angularjs interview_docs數據。我試過很多JSON編碼選項,但它沒有woked out.How得到interview_docs數據
您需要使用** ** JSON_FORCE_OBJECT'回聲json_encode($陣列,JSON_FORCE_OBJECT)' –
沒有變化@saad –
你需要證明你是如何產生'$ array'。你做了一個'print_r($ array ['interview_docs'])'以確保它在編碼之前確實包含了數據? –