带有while循环的json_encode数组到json对象

时间:2017-10-03 11:19:29

标签: php angularjs arrays json loops

我通过while循环获取我的数据

$data = array();
while ($row = mysqli_fetch_assoc($do)) {
$data[] = array('id' => $row['id'],'email' => $row['email'],'phone' => 
    $row['num_phone'],'name' => $row['name']);
}
echo json_encode($data);
print_r($data);

console.log中的输出

[{"id":"1","email":"ali.@gmail.com","phone":"555555","name":"jjj"},
{"id":"4","email":"hh@yh.com","phone":"5555","name":"iii"},
{"id":"12","email":"ali@gmail.com","phone":"202","name":"twitter"},
{"id":"14","email":"exa@hotmail.com","phone":"949942","name":""}]

print_r function

[0] => Array
        (
            [id] => 1
            [email] => ali@gmail.com
            [phone] => 5999999
            [name] => a
        )

[1] => Array
    (
        [id] => 4
        [email] => hh@yh.com
        [phone] => 5555
        [name] => iii
    )

[2] => Array
    (
        [id] => 6
        [email] => ali@hotmail.com
        [phone] => 703
        [name] => dddd
    )

[3] => Array
    (
        [id] => 7
        [email] => man@hotmail.com
        [phone] => 8757362
        [name] => new
    )

我想要获取td但未显示

<tr ng-repeat="val in show">
<td>{{val.id}}</td>
<td>{{val.name}}</td>
<td>{{val.email}}</td>
<td>{{val.num_phone}}</td>
</tr>

0 个答案:

没有答案