Re: String to Array or Hash Table

From: Date: Sun, 19 Oct 2003 12:28:57 +0000
Subject: Re: String to Array or Hash Table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166660@lists.php.net to get a copy of this message
Zheng -- ..and then sun zheng said... % % Hi, all, Hi! % .. % I explode it first by "&". % $execoutput = % "approved=yes&error=&authnumber=025968&transactionnumber=313869"; % $execoutput_array = explode("&", $execoutput); I don't see any problem with this. % % I secondly explode every parameter=value string by "=".. % % for (@reset($execoutput_array); % list($key,$value)=@each($execoutput_array);) % { % #output the result for debugging % $value_array = explode("=", $value); I don't see a particular problem with this, either, though someone might be able to do it more efficiently. % 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. HTH & HAND :-D -- David T-G * There is too much animal courage in (play) davidtg@justpickone.org * society and not sufficient moral courage. (work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#166660) next »