php-get data from form through get method -


test.php?t=xxx,y=sss 

this how user inputs data script.

how can data array inside test.php, , remove commas?

$temp = explode(',', $_get['t']); $t = $temp[0]; $y = substr($temp[1],2); 

will want url gave, @tudor constantin has best solution.

edit

this loop through many fields have. finish in $result in correct order.

$temp = explode(',', $_get['t']); foreach($temp $var){     if(strpos($var, '=')){         $exp = explode('=', $var);         $result[] = $exp[1];     } else $result[] = $var; } 

then var_dump $result gives result

array     0 => string 'xxx' (length=3)     1 => string 'sss' (length=3)     2 => string 'ttt' (length=3)     3 => string 'uuu' (length=3) 

edit 2
or try this:-

say url "test.php?t=xxx,y=sss,z=ttt,a=uuu"

$temp = explode(',', $_get['t']); $key = array_keys($_get); $temp = array_reverse($temp); $result[$key[0]] = array_pop($temp); array_reverse($temp); foreach($temp $var){     $exp = explode('=', $var);     $result[$exp[0]] = $exp[1]; } 

then var_dump($result); give you:-

array  't' => string 'xxx' (length=3)  'a' => string 'uuu' (length=3)  'z' => string 'ttt' (length=3)  'y' => string 'sss' (length=3) 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -