Last active
September 29, 2018 12:02
-
-
Save ogabrielguerra/b3f9282dbb78fe8192b89dd093619380 to your computer and use it in GitHub Desktop.
A PHP method to convert JSON attributes into object attributes.
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
function convertJsonToObjAttributes($json){ | |
$keys = array_keys((array)$json); | |
$jsonSize = count($json); | |
for( $i=0; $i<$jsonSize; $i++ ) | |
$this->{$keys[$i]} = $json[$keys[$i]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment