Home  >  Article  >  Backend Development  >  PHP array classification and array creation examples explained

PHP array classification and array creation examples explained

jacklove
jackloveOriginal
2018-05-22 17:51:341939browse

This article explains PHP array classification and array creation examples.

1. Array classification

1. Index array

Array whose index value is an integer

2.Associative array

Index value For arrays of strings, use strings as indexes, which makes programming more user-friendly!

This is very rare in other programming languages, but it will be widely used in PHP during the development process.

It is extremely convenient to use!

2. Array creation

Creating arrays in PHP is very flexible. Unlike many other programming languages, PHP does not need to

specify the size of the array when creating it. You can store any type of data in the same array without even declaring it before using it.

. You can create an array by directly assigning values ​​to the array elements.

. Use the array() language structure to create an array.

1. Create an array by directly assigning values ​​​​to the array elements

Variable name [index value] = data content; the index value can be an integer or a string, or it must be written (default is an index array) 2. Use the array() language structure to create an array. Variable name=array(key1=>value1,...);

##