Created
March 6, 2018 17:40
-
-
Save javedbaloch4/73bbed308b79f5e72b4c74250e9b1023 to your computer and use it in GitHub Desktop.
PHP - Convert Array into Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Array | |
$brands = ['electronics' => ['Dell','Hp','Compaq','Acer']]; | |
// Encode Array into JSON | |
$json = json_encode($brands); | |
// Decode the json data, Object is ready | |
$object = json_decode($json); | |
// Check the result | |
echo "<pre>", print_r($object), "</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment