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
Post a Comment