Last active
May 19, 2022 11:06
-
-
Save cp-sumi-k/1e67f9acb3fb4c2b488e9241c9f70974 to your computer and use it in GitHub Desktop.
https://blog.canopas.com/php-useful-encoding-and-decoding-functions-you-need-to-know-210e523a065f - json_encode
This file contains hidden or 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 | |
# Example 1 (Associative array) | |
$users = array(array("id"=>"1", "name"=>"John"), array("id"=>"2", "name"=>"Michel")); | |
echo json_encode($users); | |
# output: [{"id":"1","name":"John"},{"id":"2","name":"Michel"}] | |
# Example 2 (Indexed array) | |
$users = array("John", "Michel"); | |
echo json_encode($users); | |
# output: ["John","Michel"] | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment