Home > Backend Development > PHP Tutorial > php creates numerical array

php creates numerical array

WBOY
Release: 2016-07-29 09:04:37
Original
1198 people have browsed it

Beginners to PHP, in this program we can see how to create an array value, and use the count function to get the length of the array

and how to traverse the array, what we can also see in this program is Some basic syntax in php.






$cars = array("Volvo","BMW","tOyota" );//The first step is to create an array that automatically assigns id values
echo "I like ". $cars[0].",".$cars[1].",".$cars[2].".";//Output array, this output is output to the screen
print("The length of the array is :");//Print the length of the array
echo count($cars);//Use the function to calculate the length of the array
$carss = array("Volvo","BMW","Toyota");//
$ number=count($carss);//Use the function to calculate the length of the array, return a data, and assign the data to a variable
for($x=0;$x<$number;$x++)
{
echo $cars[$x];//Output array
echo "
";
}
?>


The above introduces the creation of numerical arrays in PHP, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template