Easy way to send back variables from php to unity ?

Hi

I try to get back some data from php after login for example I use most common example of communication. This is part of my function

    function Login() {
        var form = new WWWForm(); //creating a new form connection
        form.AddField( "myform_hash", hash ); /
        form.AddField( "login", formNick );
        form.AddField( "password", formPassword );
        var w = WWW(URL, form); //here we create a var called 'w' and we sync with our URL and the form
        yield w; //we wait for the form to check the PHP file, so our game dont just hang
        if (w.error != null) {
            print(w.error); //if there is an error, tell us
        } else {
            print("Test ok");
			print(w.data);
            formText = w.data; //here we return the data our PHP told us
}

So in response I get string containing all data showed by echo function in php script. It is very complicated to retrieve variables form that string. So Is there an easier way to send back variables form PHP to Unity JS ?

You may want to format your PHP output for easier parsing by the client.

JSON is a popular and robust option that’s supported in most languages. MiniJSON and JsonFx are both popular JSON libraries that work in Unity.

If you’re not sending much data, you could go for a CSV (comma-separated value) format, or put each value on its own line.

Can you tell me how you extract info sended in that way (put each value on its own line). I know that I have to do some operations on string (and currently I do it similiar way) but I dont know how to extract that info correctly. If you could give me some sample code in js how to extract that data and write to vairables in js, I would be very glad :wink: