micky007 Posted August 20, 2020 Share Posted August 20, 2020 Hi, I have a string with the value of { "success": true, "delivered": true, "contactDetailsRequired": false, "message": "Signed For by: D ANDERSON ", "signature": "https://webservices.thedx.co.uk/PodImage/ImageHandler.ashx?tn=906732192165", "date": "21-07-2020", "serviceLevelName": "Consigned", "time": "13:33:19", "trackedProductName": "DataExchange" } How do i go about placing the values into variables so for example: $success = "true"; $delivered = "true"; $message = "Signed for by: D ANDERSON"; etc.... My mind has gone blank and im having one of those days, any help would be greatly appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/311354-string-values-into-variables/ Share on other sites More sharing options...
Barand Posted August 20, 2020 Share Posted August 20, 2020 As the string is JSON, use json_decode(); EG $str = '{ "success": true, "delivered": true, "contactDetailsRequired": false, "message": "Signed For by: D ANDERSON ", "signature": "https://webservices.thedx.co.uk/PodImage/ImageHandler.ashx?tn=906732192165", "date": "21-07-2020", "serviceLevelName": "Consigned", "time": "13:33:19", "trackedProductName": "DataExchange" }'; $data = json_decode($str); echo $data->message . '<br>'; //--> Signed For by: D ANDERSON echo $data->date . '<br>'; //--> 21-07-2020 Quote Link to comment https://forums.phpfreaks.com/topic/311354-string-values-into-variables/#findComment-1580788 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.