php for loop through the array index

Traversing the word, then a full explanation is that a read access time, displayed literally.

Since for a simple loop count is circulating, and the subscript value of the array index is an integer. Therefore, we can iterate through the array index for loop.

? <PHP 

// declare an array values are 1 to 10 
$ NUM = Array (1,2,3,4,5,6,7,8,9,10); 

// accordance with the characteristics of the array index, the subscript start from zero. Therefore, the subscript index of 1 to 0,10. 9 
echo $ NUM [0] '<br />';. 
Echo $ NUM [. 9] '<br />';. 


// we can obtain an array element the total number, of 10 
echo COUNT ($ NUM); 

// traverse the array index, we can define a variable I $ 
@ I $ 0 value, starting from 0 
@ cycle can be set to a conditions: $ i lower target (9) loop within the maximum value 
for ($ I = 0; $ I <COUNT ($ NUM); $ I ++) { 

 echo $ NUM [$ I] '<br />';. 

} 

?>

  

Guess you like

Origin www.cnblogs.com/furuihua/p/11698224.html