We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › to distinguish multiple echo from php page
Page Index Toggle Pages: 1
to distinguish multiple echo from php page (Read 265 times)
to distinguish multiple echo from php page
Jun 27th, 2008, 10:48am
 
hi there
i am calling a php page using processing and am echoing lots of different contents on that page.
i want to receive all that content in processing but processing is receiving all the echo as a single element of the array

can anyone suggest how to differentiate the different contetnts being echoed by php page?
Also since the echoed matter is actually text from web so breaking the string based on delimiters may not be very good idea in this case.


The processing code:

 String [] position;
 int num,num1;
void setup()
{
 background(255,255,255);
 String url = "http://turing.lecolededesign.com:16080/~rshukla/gui_feed.php";
 position = loadStrings(url);
 //num= int(position[0]);
 //println(num);
 println(position);
}

void draw()
{

}

the php page
http://turing.lecolededesign.com:16080/~rshukla/gui_feed.php
Re: to distinguish multiple echo from php page
Reply #1 - Jun 27th, 2008, 11:30am
 
the simplest solution is to modify the php script so each string echoed is escaped with "\n":

Code:
<?php
echo "line a\n";
echo "line b\n";
?>

then, you'll get your array of strings just using loadStrings() as you did.


otherwise, if you can't modify the php script, try spliting the string you got with the "http://" token :

Code:
String[] links = split(position[0], "http://");
for (int i = 1; i < links.length; i++)
 println("http://" + links[i]);

will return the list of the webpages.


Re: to distinguish multiple echo from php page
Reply #2 - Jun 27th, 2008, 11:47am
 
thanks ....
it was elegant and it works
Page Index Toggle Pages: 1