title: Cleaning Up Formatted JSON converted from PHP Array
body: <p>I'm trying to get the following formatting in JSON using PHP which is querying the database... notice there is no final comma</p>
  
  <pre><code>[
        {
          "ID": "4",
          "Name": "Jill Higgins",
          "Job Title": "Designer",
          "Organisation": "Design Widget",
          "Organisation Type": "Academia",
          "Latitude": "54.669978",
          "Longitude": "-1.452469"
      },
      {
          "ID": "5",
          "Name": "Bob Billy",
          "Job Title": "Clown",
          "Organisation": "Big Comp INC",
          "Organisation Type": "Company",
          "Latitude": "54.669978",
          "Longitude": "-1.452469"
      }
  ]
  </code></pre>
  
  <p>This is my code currently... </p>
  
  <pre><code>if (PerchUtil::count($members)) {
  
  echo '[';
  
  foreach ($members as $Member) {
    //prepare the data
    $data = array(
      'ID' =&gt; $Member-&gt;memberID(),
      'Name' =&gt; $Member-&gt;first_name() . ' ' . $Member-&gt;last_name(),
      'Job Title' =&gt; $Member-&gt;expert_job_title(),
      'Organisation' =&gt; $Member-&gt;expert_org_name(),
      'Organisation Type' =&gt; $Member-&gt;expert_org_type(),
      'Latitude' =&gt; $Member-&gt;expert_org_latitude(),
      'Longitude' =&gt; $Member-&gt;expert_org_longitude()
    );
  }
  echo ']';
  }
  
  header('Content-Type: application/json');
  </code></pre>
  
  <p>This is what it currently looks like... notice there is a comma at the end which <strong>I don't need</strong>. The spacing isn't really helpful with the brackets either... how do I amend the PHP so it is cleaner and counts out the final comma?</p>
  
  <pre><code>[{
      "ID": "4",
      "Name": "Jill Higgins",
      "Job Title": "Designer",
      "Organisation": "CPI",
      "Organisation Type": "Academia",
      "Latitude": "54.669978",
      "Longitude": "-1.452469"
  },{
      "ID": "5",
      "Name": "Bob Billy",
      "Job Title": "Clown",
      "Organisation": "Big Comp INC",
      "Organisation Type": "Company",
      "Latitude": "54.669978",
      "Longitude": "-1.452469"
  },]
  </code></pre>