Array ( [edit] => true [id] => 1 [type] => Array ( [0] => LC ) [userid] => 1 [norooms] => 1 [park] => Central [start] => 09:00 [end] => 11:00 [length] => 2 [student] => 79 [status] => Rejected )
<?php
$posted_data = array();
if (!empty($_POST['edit'])) {
$posted_data = json_decode($_POST['editVal'], true);
}
print_r ($posted_data);
foreach ($posted_data as $key => $value) {
echo '<p>'.$key.'</p>';
echo '<p>'.$value.'</p>';
}
?>
在頂部的陣列是返回的jason_decode
。但是,使用我的foreach
函數,它不顯示數組中的第一個索引。即。 ([0] => LC)
。如何從數組中返回所有結果?
我哪裏錯了?
提供的答案很好,如果你想向用戶顯示數組並且需要格式化html的能力......但是如果你只是想查看數組以便調試,請查看print_r和/或var_dump。 – DragonYen