php - How to do a multidimensional array within a while loop? -


im stuck simple problem in php:

$words = array(); while ($allrow = mysqli_fetch_array($all)) {            $words = "".utf8_encode($allrow["eng"])."" => "".$allrow["id"]."";                   }  foreach ($words[] $key => $word) { 

i wanna have array words , id. in foreach loop need able know id each word has.

you array building syntax off, try this:

// array key id, swap if needed, assume ids unique $words[$allrow["id"]] = utf8_encode($allrow["eng"]); 

every time $words = $anything, overwriting last iteration.

this should have generated parse error:

."" => "". 

not sure how slipped testing. no need empty "" strings either.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

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

url - Querystring manipulation of email Address in PHP -