Array loop traversal print results Little brother I did not understand when I was learning, to ask you next

Source: Internet
Author: User
Array loop traversal print out results I didn't read it when I was studying, and I asked you for advice.
When I was learning PHP, I saw the array looping through the printout, and there was a sentence that didn't read.
The code is as follows

$arr [0]=1;
$arr [1]=2;
$arr [2]=3;
$arr [3]=4;
Cycle start
for ($i =0; $i <4; $i + +) {
echo $i. $arr [$i]; May I ask you $arr[$i] This sentence is what meaning, why to put the loop $i this variable, put into the array $arr inside go
}

------to solve the idea----------------------
They're all subscript and PHP subscript is starting from 0 is subscript 0 corresponds to the first number 1 corresponds to a second number and so on
------to solve the idea----------------------
This is the loop, when $i=0, $i =1, $i =2, $i = 3 o'clock, respectively output $ARR[0], $arr [1], $arr [2], $arr [3] value.
------to solve the idea----------------------
Looking at the definition of the array, the subscript represents the position of the array value at the index.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.