How to return PHP array and receive it with Java
<p>I have this on my webservice:</p>

<pre><code> function listar($username)
{
    $result = mysql_query("SELECT Name FROM APKs WHERE Tipo=0");
    //$registo = mysql_fetch_array($result);

    $numero = 0;
    while($registo = mysql_fetch_array($result))
    {
        $regs[$numero] = $registo['Name'];
        $numero++;
    }

    return $regs;

    //return mysql_fetch_array($result);

}
</code></pre>

<p>in Java, after the SOAP call (not relevant now) I read it this way:</p>

<pre><code>Object response = envelope.getResponse();
String x = response.toString();
</code></pre>

<p>I need to access which one of those fields (selected from the database) so I thought, why not split the array into strings?</p>

<p>I tried two methods:</p>

<pre><code>String[] arr=x.split(&amp;quot; &amp;quot;);
        System.out.println(&amp;quot;Array :&amp;quot;+arr.length);
        for(int i=0;i&amp;lt;arr.length;i++)
        {
            ..
        }

        StringTokenizer stArr=new StringTokenizer(x,&amp;quot; &amp;quot;);
        while(stArr.hasMoreTokens())
        {
            ...
        }
</code></pre>

<p>But none of them worked, whick make me believe I'm returning badly the array in first place.</p>

<p>Any help?</p>

<p><strong>UPDATE:</strong></p>

<ul>
<li><p>So I'm using again xsd:string;</p></li>
<li><p>Now I have on my webservice return json_encode($regs);</p></li>
<li><p>To convert the object from the response I'm using a specific google api
<a href="http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/" rel="nofollow">http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/</a></p>

<p>Object response =  envelope.getResponse();
Gson gson = new Gson();
String jstring = gson.toJson(response);</p></li>
<li><p>But I'm with difficulty parsing the "jstring" because it's format: "[\"SOMETHING\",\"SOMETHING\",\"SOMETHING\",\"SOMETHING\",.....]". I have not any identifier to get those values.</p></li>
</ul>

<p>How can I extract those dynamic values and assign them to String[]?</p>
