cabarlah Posted August 3, 2021 Share Posted August 3, 2021 Hi, im working on a Stripe API, trying to extract the email address from the payment customer details. How do I get the email from the following string "customer_details":{"email":"emailaddress@gmail.com","tax_exempt":"none","tax_ids":[]} I have been using the following which returns the entire string: $payment->customer_details Would like to only return the email address, but I am unsure how to achieve this (sorry PHP newbie here) Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted August 3, 2021 Solution Share Posted August 3, 2021 The string you posted appears to be missing its enclosing { .. }. With those it becomes a correctly formatted JSON string... $details = '{"customer_details":{"email":"emailaddress@gmail.com","tax_exempt":"none","tax_ids":[]}}'; you can then decode the string... $data = json_decode($details); then access the email address with... $email = $data->customer_details->email; 1 Quote Link to comment Share on other sites More sharing options...
cabarlah Posted August 3, 2021 Author Share Posted August 3, 2021 Thank you Barand, YES that has worked, much appreciated 😀 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.