- Home /
How to split a string data?
I tried to create a leader board as unity wiki server side high score in c#
the PHP send that data to Unity:
echo $row['score'] ."\t". $row['name'] . "\n";
and unity receive that via www class:
WWW hs_get = new WWW (highscoreURL);
yield return hs_get;
my question is how to split this data to define something like:
string player_one_name = ? ;
int player_one_score = ?;
//
string player_two_name = ? ;
int player_two_score = ?;
Not that familiar with php, could you post the actual string that pops out of the WWW?
You're looking for string.Split, though. Look here for details, that should probably be enough.
You could send a json and use a json parser to parse the object properly (I recommend this).
Else you can use the split function for a string and use a special character to separate your items so you would need to do some operations on you rows from your php script.
$row is the result of a sql request? can you show the echo value?
Your answer
![](https://koobas.hobune.stream/wayback/20220613200708im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Extend from box. Notes 2 Answers
NullReferenceException when transform.Find(string) STILL 1 Answer
String Arrays in a function 0 Answers
Using Polish characters in OnGUI 1 Answer
Unity JS Equivalent of split()? 2 Answers