I'm trying to write a script to accept data from an iPhone app onto a webpage. The data is a user signup. Once the user is signed up, I need to throw back in JSON a success message, the users ID and the table name like this: I need to list the table name within a custom JSON encoded array like this: { "users": [ { "success":"true" ,"userID":".$row['userID']."} ] } PHP: This is what I have so far, but I'm really struggling to get the table name within the JSON array but outside of the variables; //Account created, generate success response $message = array( 'success'=>'true', 'userID'=>''.$row['$userID'].'' ); echo json_encode($message); } PHP: It looks like this:
$message = array( 'users' => array( 'success'=>'true', 'userID'=>''.$row['$userID'].'' ) ); echo json_encode($message); PHP: This should do it.
Nope, I need it to be in the square brackets like this: { "users": [ { "success":"true" ,"userID":".$row['userID']."} ] } Code (markup):
Managed to get it working with: //Account created, generate success response $message = array( "users" => array (array( 'success'=>'true', 'userID'=>''.$row['userID'].'' ))); echo json_encode($message); PHP: