base64 Decode into PHP Array -



base64 Decode into PHP Array -

i'm trying create web panel client parses info base64 encoding. have set way decode it, , if echo decoded part in loop ($data[1]), write right information. however, need able set info sql table , perform work on before that. so, i'm trying set info array, acting array empty reason.

$postdata has base64 decoded information, , exploded using & exploding agent.

$tokens = array (); ($i = 0; count($postdata) > $i; $i++) { $data = explode("=", $postdata[$i]); $tokenadd = array(); $tokenadd[] = $data[1]; array_push($tokens, $tokenadd); } var_dump($tokenadd);

are shure dumping right variable? because $tokenadd rewritten on each iteration.

$tokens = array (); ($i = 0; count($postdata) > $i; $i++) { $data = explode("=", $postdata[$i]); // token empty array; $tokenadd = array(); $tokenadd[] = $data[1]; // force array 1 string element $tokens array_push($tokens, $tokenadd); } // dump $tokens, not $tokenadd var_dump($tokens);

to simplify code yput may seek this

$tokens = array(); foreach ($postdata $postdataitem) { $data = explode("=", $postdataitem); $tokens[] = array($data[1]); } var_dump($tokens); // array(array('containing'), array('some'), array('strings'))

or more simple, if ok dealing not array of array , array of strings

$tokens = array(); foreach ($postdata $postdataitem) { $data = explode("=", $postdataitem); $tokens[] = $data[1]; } var_dump($tokens); // array('containing', 'some', 'strings')

php arrays loops base64

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -