Re: String to Array or Hash Table
| From: | sun zheng | Date: | Sun, 19 Oct 2003 15:10:33 +0000 |
| Subject: | Re: String to Array or Hash Table | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-166662@lists.php.net to get a copy of this message | ||
tx for the reply.. ya, it is what i am looking for.. however, your solution is not the right one.. please help me to adjust it a lot..
let us come back to the initial string .. "approved=yes&error=&authnumber=025968&transactionnumber=313869";
after the statement "for (@reset($value_array); list($key1,$value1)=@each($value_array);)",
currently in the array $value_array, it contains such key<->content
key1=0, $value1="approved=yes"
key1=1, $value1="error="
key1=2, $value1="authnumber=025968"
key1=3, $value1="transactionnumber=313869"
therefore current $approved = $value_array['approved'] ; is empry.. i cannot get "yes" ..
I definately want to get something like
$value_array['approved'] is "yes"
$value_array['error'] is ""
$value_array['authnumber'] is "025968"
$value_array['transactionnumber'] is "313869"
please think about it once more..
thanks again..
% for (@reset($value_array); list($key1,$value1)=@each($value_array);)
% {
% $first = $value1;
% list($key1,$value1)=@each($value_array);
% $second = $value1;
I don't think you need to do this, though, because ...
%
% if($first == "approved")
% {
% $approved = $second;
% }
[snip]
... I don't think you need to go through all of these if() tests.
You have each key and value in your value_array; you should be able
to just say
$approved = $value_array['approved'] ;
and so on.
This is untested and I am in a hurry, but I hope it puts you on the right
track.
with best wishes
Zheng Sun
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail