Php does not need to specify its size when creating an array. Since php is a loose language, you do not even need to declare it before using arrays. Although there are no strict restrictions, php still provides formal and informal array declaration methods. Php does not need to specify its size when creating an array. Since php is a loose language, you do not even need to declare it before using arrays. Although there are no strict restrictions, php still provides formal and informal array declaration methods. This article will introduce two methods for creating php arrays for your reference. Method 1: directly create an array using the value assignment method. below we will create an array containing the name of the script School: The next group of arrays in php also starts from 0. Output array: If you want to modify the value of an array, you can directly assign a value to the array of the current index. for example, if the index value of an array is a numerical index and increases progressively, you can also omit the index value during creation: it is very easy to create an associated array in this way, but you must always use the key. Let's take a look at the example below: Finally, let's talk about another method to create a php array, that is, using the array () function. The array () function accepts 0 or more elements as input, and returns an array containing these input elements. The format is as follows: array ([item1 [, item2... [, itemN]) For example: Well, the method for creating an array in php is described here. I hope it will help you. Programmer's house, dedicated to you. |