Good day everyone.
I study PCH. I encountered such a problem as outputting an array through a for loop, with different indices (keys)
Code itself

$f_a = ["int1"=>1,"int2"=>2,"int3"=>3,4,5,6,7]; for($i = 0; $i < count($f_a);$i++){ if(isset($f_a[$i])) echo $f_a[$i]; elseif(isset($f_a["int".$i])) echo $f_a["int".$i]; } 

Display on screen

4567

That is elements with a standard index
What could be the problem, I just can not understand ..
Thank you in advance for your response.

    1 answer 1

    To iterate over associative (in which keys are not just numbers) arrays are used by foreach

     $f_a = ["int1"=>1,"int2"=>2,"int3"=>3,4,5,6,7]; foreach ($f_a as $key => $value) { echo $value.'<br>'; }