Php creates a numeric array

Source: Internet
Author: User
: This article mainly introduces how to create a value array in php. if you are interested in the PHP Tutorial, refer to it. In this program, we can see how to create an array value and use the count function to obtain the length of the array.

And how to traverse the array. in this program, we can also see some basic syntax in php.







$ Cars = array ("Volvo", "BMW", "tOyota"); // you can create an array that automatically allocates id values.
Echo "I like ". $ cars [0]. ",". $ cars [1]. ",". $ cars [2]. ". "; // output array, which is output to the screen
Print ("The length of the array is:"); // print the length of the array
Echo count ($ cars); // use a function to calculate the length of an array
$ Carss = array ("Volvo", "BMW", "Toyota ");//
$ Number = count ($ carss); // use a function to calculate the length of an array, return a data value, and assign the value to a variable.
For ($ x = 0; $ x <$ number; $ x ++)
{
Echo $ cars [$ x]; // output array
Echo"
";
}
?>


The above describes how to create a value array in php, including some content. I hope to help anyone who is interested in the PHP Tutorial.

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.