Add response code in json

I have a php script that gives response in json for my android applicaiton.

The json :

{"0":"1","id":"1","1":"mahmudul hasan","name":"mahmudul hasan","2":"364","roll":"364","3":"sohel","qrcode":"sohel"} 

But i also want to get status with the resonse like below :

 {   "0": "1",   "1": "mahmudul hasan",   "2": "364",   "3": "sohel",   "id": "1",   "name": "mahmudul hasan",   "roll": "364",   "qrcode": "sohel",   **"success": true**  } 

My PHP coed for json response :

    foreach ($data as $item)     {         if($item!=NULL)         {             echo json_encode($item);          }         else         {             echo json_encode($item);                     }     } 

How should i add the response status ?

Replay

try something Like this

 foreach ($data as $item)
    {
        if($item!=NULL)
        {
            $item['status'] = true;
            echo json_encode($item);
        }
        else
        {
            $item['status'] = true;
            echo json_encode($item);
        }
    }

Category: php Time: 2016-07-29 Views: 0
Tags: php json

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.222 (s). 12 q(s)