Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by filler03 · Jul 16, 2012 at 08:34 AM · wwwstringphpwwwform

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by flamy · Jul 16, 2012 at 09:30 AM

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image filler03 · Jul 16, 2012 at 06:07 PM 0
Share

Can the method you showed only be done in c#?

avatar image flamy · Jul 16, 2012 at 07:27 PM 0
Share

ofc it can be,,, i always use c#!!!

avatar image filler03 · Jul 16, 2012 at 09:13 PM 0
Share

I think the xml method would work better for me because i will be having alot of values. How would I go about doing this?

avatar image flamy · Jul 17, 2012 at 05:03 AM 0
Share

check ivan's answer in this link for creating xml document in php.... and to retrieve it in unity3d check the link in my answer above..

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

PHP POST through $_REQUEST with WEBBUILD 1 Answer

WWW Class is acting up 1 Answer

www.data and string conversion to integer 2 Answers

Problem using WWW with PHP and MYSQL 3 Answers

wwwform send an array the right way! 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges