Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Example 1:
- <?php
- $result_attrs = array(
- array(
- 'id' => 1,
- 'name' => "name1"
- ),
- array(
- 'id' => 2,
- 'name' => "name2"
- )
- );
- $response = array (
- 'status' => 0,
- 'message'=> "success",
- 'result' => $result_attrs
- );
- echo json_encode($response);
- Example 2:
- $result_attrs = array();
- $fetch = mysql_query("SELECT * FROM table");
- while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
- $row_array['id'] = $row['id'];
- $row_array['name'] = $row['name'];
- array_push($result_attrs, $row_array);
- }
- $response = array (
- 'status' => 0,
- 'message'=> "success",
- 'result' => $result_attrs
- );
- echo json_encode($response);
Add Comment
Please, Sign In to add comment