+ 1
How can I use an array with a for loop?
I want to get a database results in array; Ex: $nameEmployee=array( $show_name['namEmployee'], $show_name['firstnameEmployee']);
2 Answers
+ 1
If you want to iterate through an array, you can use the for or foreach loop:
for ($i = 0; $i < {arrlength}; $i++) {
//code, use arr[$i] to access nth element;
}
foreach(arr as $i) {
//code, use $i to access nth element
}
+ 1
Great, thank you very much