php_begins Posted September 18, 2012 Share Posted September 18, 2012 My function returns a bunch of attribute ids and it's corresponding names in json format. For eg: { "DETAILS": [ { "ATTR_ID": "522", "ATTRIBUTE_ID": "4222", "ATTRIBUTE_TYPE": "email", }, { "ATTR_ID": "523", "ATTRIBUTE_ID": "4006", "ATTRIBUTE_TYPE": "interest", } ] } I need to store it in an array which i need to cache .( I'll be probably using $_SESSION) Now another function returns me set of attribute ids: $val_array = $subarray[arrayOfAttributes]; foreach ($val_array as $val) { print "Attrib Value: $val\n"; //This will print ids 4222,4223,etc } what I need to do is correspond the ids with the type from the cache nad print out the respective Types. I am unable to formulate this logic into code. Quote Link to comment https://forums.phpfreaks.com/topic/268485-retrieving-json-data-and-cache-it-for-future-reference/ Share on other sites More sharing options...
Christian F. Posted September 18, 2012 Share Posted September 18, 2012 First of all you'd want to use json_decode () to get that array of yours. Next is to loop through it, and check if the attribute_id is in the $val_array. If it is, then you know you can print it to screen. Quote Link to comment https://forums.phpfreaks.com/topic/268485-retrieving-json-data-and-cache-it-for-future-reference/#findComment-1378827 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.