我从android获得一个jsonobject,并在使用json_decode()解码后以此格式获取它,现在我想将这些数据插入到数据库中。我如何获取这些数据,请帮助... 提前谢谢...
Array
(
[0] => Array
(
[name] => ramesh
[empid] => emp32451
)
[1] => Array
(
[name] => Ranjith
[empid] => emp89884
)
)
PHP:
<?php
header('Content-type: application/json');
$decoded= json_decode($_POST['submit_data']);
json_encode($decoded);
$emplist = $decoded;
print_r ($emplist);
?>
答案 0 :(得分:0)
尝试将print_r()行添加到此处,以获取数组中的值。
for ( $i = 0; $i < count( $emplist ); $i++ ) {
$name = $emplist[$i]["name"];
$empid = $emplist[$i]["empid"];
// write to the database in the database's specified manner
}