0

im trying to get single value from array which is in other file, this is my code so far

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

And this is part of my array file:

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
                )

OUTPUT IS

 A
  • $data = file_get_contents('order.log', true); return a string, not an array – Antonio Abrantes Apr 30 '20 at 00:18
  • A is from Array the first letter of this string – Antonio Abrantes Apr 30 '20 at 00:19
  • 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 ) ) ) – Antonio Abrantes Apr 30 '20 at 00:20
  • The `print_r` format (that's what this is) cannot be extracted back easily. Fix your storage approach first. – mario Apr 30 '20 at 10:38

0 Answers0