php - Array values into foreach loop don't display correctly -


the following array result of query fetched array

$array2 = mysqli_fetch_all($par_cat, mysql_num);  

array

array(10) {   [0]=>   array(2) {     [0]=>     string(3) "365"     [1]=>     string(7) "man"   }   [1]=>   array(2) {     [0]=>     string(3) "381"     [1]=>     string(5) "woman"   }   [2]=>   array(2) {     [0]=>     string(3) "347"     [1]=>     string(4) "kid"   }   ...... } 

the values should displayed foreach loop implemented as:

html

<select class='form-control'>       <?php      foreach ($array2 $key => $value){        echo '<option value="' .$value . '">' . $key . '</option>';       }       echo '<select>';    ?> 

result

https://pasteboard.co/ggehdu5.png

the issue on listed values shown in link above. result gives number of values not values (such man, woman, kid etc...)

i can't figure out how make reference them foreach loop.

any help?

the numeric values indexes, produced $key, , rows represented $value. swap in code, , take correct value (from column 1), have:

echo '<option value="' . $key . '">' . $value[1] . '</option>'; 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -