convert array和unserialize [“bill_details”]打印值

时间:2017-07-02 10:53:44

标签: php arrays

print_r ($bill_details);

结果

Array
(
    [0] => Array
        (
            [id] => 355
            [bill_details] => 19.90
            [st_id] => 0
            [user_id] => 0
            [status] => 0
        )

)

2 个答案:

答案 0 :(得分:0)

foreach ($array as $key => $value){
     echo "Key is $key and value is $value";
}

echo $array[0]['id'];

然后你可以获得key的当前值。谢谢

答案 1 :(得分:0)

当您在数组内部使用数组时,您可以使用foreach中的foreach获取每个值,如

<?php
$bill_details[] = array("id" => 355, "bill_details" => 19.90, "st_id" => 0, "user_id" => 0,"status" => 0);
print_r($bill_details);

foreach($bill_details as $key => $value){
    foreach($value as $vala){
        echo $vala;
    }
}
?>