Re: String to Array or Hash Table

From: Date: Sun, 19 Oct 2003 16:25:34 +0000
Subject: Re: String to Array or Hash Table
Groups: php.general 
Request: Send a blank email to php-general+get-166664@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";
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"
If I'm wrong, blame this on coming into the thread at this stage, not the beginning. That string look suspiciously like a GET request. $myvars = array('approved', 'error', 'authnumber', 'transactionnumber'); foreach ($myvars as $key) { $value_array[$key] = $_GET[$key]; } If it's just a string, something like: $data_array = split('&', $string); foreach ($data_array as $key) { list($mykey, $value) = split('=', $key); $value_array[$mykey] = $value; } ################################################### thank you.. but .. it is still different as what i expect... :( ya, it is only a string, not a link which could be captured by $_get[].. :( "approved=yes&error=&authnumber=025968&transactionnumber=313869" let's just take a look at your final array "$value_array[$mykey] = $value;" key <-> content will be 0 - approved 1 - yes 2 - error 3 - null 4 - authnumber 5 - 025968 6 - transactionnumber 7 - 313869 I want to get something like hashtable.. key <-> content approved <-> yes error <-> null authnumber <-> 025968 transactionnumber <-> 313869 is it possible ? otherwise i have to reserve my old way listed in the first thread, using four "if" which is ugly.. :(( with best wishes Zheng Sun _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus

« previous php.general (#166664) next »