title: How to convert JSON to array in PHP?
body: <p>While receiving the following JSON</p>
  
  <pre><code>{ "phone": [ "123", "456", "789"]}
  </code></pre>
  
  <p>in PHP I try to get this (displayed with <code>print_r</code>):</p>
  
  <pre><code>Array ( [0] =&gt; 123 [1] =&gt; 456 [2] =&gt; 789 )
  </code></pre>
  
  <p>Therefore I tried to use the following code, without success:</p>
  
  <pre><code>if (isset($_GET["phone"])) {
      //Decode Json
      $values = json_decode($_GET['phone'], true);
      print_r($values);
      foreach ($values as $key =&gt; $value) {
      echo "&lt;p&gt;$key | $value&lt;/p&gt;";
      }...
  </code></pre>
  
  <p>How can I receive and convert this JSON in the requested array?</p>
  
  <p>It's working fine while the JSON is defined in the php code. Then I get an associative array. In my mind the problem might be in the java (android) code because the $_GET['phone'] should work in php:</p>
  
  <pre><code> ArrayList&lt;String&gt; paramsstring = new ArrayList&lt;String&gt;();
   ArrayList&lt;BasicNameValuePair&gt; paramstodb = new ArrayList&lt;BasicNameValuePair&gt;();
   contacts = aa.toArray(new String[aa.size()]);
  
      for (int i = 0; i &lt; contacts.length; i++) {
          paramsstring.add(contacts[i]);}
  
      paramstodb.add(new BasicNameValuePair("phone", paramsstring.toString()));
  
      // getting JSON string from URL
      JSONObject json = jParser.makeHttpRequest(url_all_user, "GET", paramstodb);
  </code></pre>
  
  <p>Maybe php receives another format of that JSON? The GET request should not be the problem, because the JSON is not very long.</p>