RE: [PHP] Converting piped data from stdin to phpcgi

From: Date: Mon, 13 Feb 2006 15:33:42 +0000
Subject: RE: [PHP] Converting piped data from stdin to phpcgi
Groups: php.general 
Request: Send a blank email to php-general+get-230315@lists.php.net to get a copy of this message
[snip] I am using php as a cgi. The data from my html is piped through stdin using this code: <? $fp=popen("cat","r"); $str=fgets($fp); print $str; ?> The result I am getting looks like this: (which is correct) sender_name=zedleon&sender_email=support@passeycorp.com&sender_msg=This+is+a +test&Submit=Submit What I need to do now is to convert the piped string into the individual values $sender_name, $sender_email, $sender_msg. Does anybody know a way to do this...any help is appreciated. [/snip] http://us2.php.net/explode http://us2.php.net/foreach $string = "sender_name=zedleon&sender_email=support@passeycorp.com&sender_msg=This+is+ a+test&Submit=Submit"; $stringArray = explode("&", $string); foreach($stringArray as $key => $value){ $partArray = explode("=", $value); echo $partArray[0] . " is equal to " . $partArray[1] . "\n"; }

« previous php.general (#230315) next »