How can the json_decode() function be utilized to convert a JSON string into a multidimensional array in PHP?
To convert a JSON string into a multidimensional array in PHP, you can use the json_decode() function. This function takes a JSON string as input and returns a PHP array. By setting the second parameter of json_decode() to true, you can convert the JSON string into an associative array instead of an object.
$jsonString = '{"key1": {"nested_key1": "value1", "nested_key2": "value2"}, "key2": "value3"}';
$multiArray = json_decode($jsonString, true);
print_r($multiArray);
Related Questions
- What are the potential issues with using the visitor's email address in the From header of an email sent via PHP?
- What is the significance of using backticks for column names in PHP MySQL queries?
- What best practices should be followed when naming classes and functions to adhere to standard conventions in PHP programming?