Skip to content
Advertisement

Tag: arrays

Convert a json to multi-dimensional PHP array

I have the following json sent to my API endpoint {“key”:”levels”,”value”:”[{role_id:1, access_level_id:3}, {role_id:2, access_level_id:1}, {role_id:3, access_level_id:2}]”,”description”:””} at the backend, I receive it as a Laravel request as follows: And it returns the following expected result array ( ‘key’ => ‘levels’, ‘value’ => ‘[{role_id:1, access_level_id:3}, {role_id:2, access_level_id:1}, {role_id:3, access_level_id:2}]’, ‘description’ => NULL, ) But I need to convert the ‘value’ to

Access data in nested array with PHP

From a web service I am reading an xml file with the following structure I then use the following php code to parse through the data I would expect the code above to display Instead my output is I am real beginner in php and cant really figure this out… Any help please? Answer $productsArray[‘StoreDetails’] is a 2-dimensional array. $value

Search for an item in inner array

I have an assoc array looking like this (the data comes from user input, this is just an example) How would I look for a specific startingDate for example if I don’t want to loop over every ID. Basically I’m looking for a way to do something like $eventDates[*][“startingDate”] Answer You can achieve this a few different ways, one being

Advertisement