I tried online unserializer tool, but failed to interpret your value, because it’s broken.
Anyway, the way to get value is like below:
// Get the value from db first
$meta_value = get_post_meta( $post->ID, 'invoice_details' , true ); //'invoice_details' is a string, not a variable
// Get to the desired value
$desired_value = $meta_value['array_key']; // value from first step of array
or:
$desired_value = $meta_value['array_key']['array_key_second']; // value from second step of array
You should var_dump($meta_value)
after having $meta_value
to get the idea how to proceed with the data.
Edit
I simply organized your array like below:
<?php
array (
'price_per_night' => '150',
'no_of_nights' => '1',
'price_calulating_nights' => '150',
'price_after_commission' => '150',
'discount_type' => '',
'price_after_discount' => '150',
'discounted_price' => '0',
'discount_percentage' => '',
'total_service_fee' => '60',
'total_price' => '210',
'currency' => 'GBP',
'post_id' => '21',
'check_in' => '02-07-2017',
'check_out' => '03-07-2017',
'guests' => '1',
'security_deposit' => '100',
'secret_key' => 'FfmtXmaPOKbrS8B1XLugufiD3Hdjxl',
'updated_at' => '2017-06-25 17:04:33',
'booking_request_by' => 2,
'step_2_attributes' => array (
'firstname' => 'Tom',
'lastname' => 'Smith',
'street_address' => '229',
'postal_code' => 'YW11 3DU',
'city' => 'London',
'country' => 'United Kingdom',
'phone' => '0799999999',
'guest_fname' => array (
1 => 'Bella',
),
'guest_lname' => array (
1 => 'King',
),
),
);
And it itself giving you the answer. Yes, just get to the nested keys:
$firstname = $meta_value['step_2_attributes']['firstname'];
If the 'firstname'
is set you will get the First Name.
For Guest First Name:
$guestFirstname = $meta_value['step_2_attributes']['guest_fname'][1];