首页 > 解决方案 > 使用 file_get_contents 时获取数组值

问题描述

我试图从其他文件中的数组中获取单个值,这是我到目前为止的代码

     $data = file_get_contents('order.log', true);
$name = $data['0']['customer_last_name'];
echo $name; 

这是我的数组文件的一部分:

Array
(
    [0] => Array
        (
            [customer_id] => 1364
            [customer_group_id] => 1
            [customer_first_name] => penna
            [customer_last_name] => Macii
            [customer_email] => mail8@abv.bg
            [customer_ip] => 1601136638
            [note_customer] => 
            [note_administrator] => 
            [quantity] => 3
            [weight] => 0
            [vat_included] => yes
            [email_sent] => 
            [status] => pending
            [customer_geoip] => Array
                (
                    [city] => Sofia
                    [state] => Sofia-Capital
                    [country] => Bulgaria
                    [country_iso] => BG
                    [timeZone] => Europe/Sofia
                    [lon] => 42.683
                    [lat] => 23.3175
                )

输出是

 A

标签: phparrays

解决方案


推荐阅读