How to end an array of json data, and echo another value?
<p>I'm using <code>php</code> to return an array of data, with the command <code>json_encode()</code>. I want to also send some other data after I send this array. I'm using the <code>jquery</code> library. My <code>php</code> code is as follows:</p>

<pre><code>&lt;?php    

////  Query
$sql = "SELECT gtn FROM $table WHERE gid &lt; 10";

//// Open connection 
$con = pg_connect("host=12.12.2.2 port=5434 dbname=spatial_data user=postgres password=****");  
if (!$con){echo 'error connecting'; die; }

//// Run query
$query = pg_query($con, $sql);
$arrayData = array(); // Store results from query in arrays

//// Parse results
while($r = pg_fetch_row($query)) {
    $arrayData[] = $r[0];
}
echo json_encode($arrayData);

//// Return metadata about calculation
//echo "$('#messages').html('Result returned for New York')";

//// close connection
pg_close($con);   

?&gt;
</code></pre>

<p>This <code>php</code> is responding to a <code>jquery</code> post command:</p>

<pre><code>$.ajax({ 
  type: "POST",
  url: "/php/array_test_v3.php",  
  data:{vertices: pointlist},  
  success: function(arrayData){  
    //console.log(arrayData[0])
    for(i=0;i&lt;arrayData.length; i++){
      setGeoJson(arrayData[i]);
    }
  }, 
  dataType:'json'
}); 
</code></pre>

<p>This is a spatial database, and when I query the information, I also want to return some other values. For example, if the area is New York, I want to return an array of data and also the string <code>New York</code>. At the moment the line <code>echo "$('#messages').html('Result returned for New York')";</code> just appends to the array of information. Is there a way that I can escape from the array, or do I need to have a separate <code>post</code> function to get this information.</p>
