Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $json = '[{
- "user_id": "1",
- "username": "Sandy Corzeta"
- }]';
- // array of users objects as is in the json code
- $users = json_decode($json);
- if (null === $users && json_last_error() !== JSON_ERROR_NONE) {
- die('Error decoding json, error code: ' . json_last_error());
- }
- ?>
- <div>
- <div id="user_id"><?php echo $users[0]->user_id; ?></div>
- <div id="username"><?php echo $users[0]->username; ?></div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment