Retrieving varibale values from a php script?

I understand how to access a webpage using the WWW class and that i can use the echo statement in php to include my variable values in www.text, but how do I seperate these values from the entire string? Thanks in advance.

i use a rough way of doing it by adding a ‘*’ after each variable value and then in unity i use String.Split function to split and parse it. It is a good method if the number of values to be echoed is less.

But proper way of doing it is using XML format. you have to echo your values as a xml formated text and in unity you can use XMLDocument class to extract it back (like this answer). But i dont prefer it since number of variables are low and also it increases the build size by an mb (which is something to worry in mobile platform.)

here is the sample of how i do it using ‘*’ delimiter.

<?php

     for($i = 0; $i < 10; $i++)
    {
      echo $i.'*';    //i am jus printing 10 values here from for loop, this need not be in loop too!.
    }

?>

And in the unity3d after getting the text.

  //assume www is the object and is yielded with the value from php bfore this step...

  string[] temp = www.text.Split("*".ToCharArray());

  // and in the temp array you can use parse to get the value back...

  int value1=  Int32.Parse(temp[0]);
  // now value 1 has the first value 0 in it.

This is a simple method to do … if the number of values are more dont prefer this method, go with XML.