PHP & gt; example 1 in this example, the ID key $ namesarray (Peter, Quagmire, Joe) is automatically assigned; example 2 in this example, manually assigned ID keys: $ names [0] Peter; $ names [1] Quagmire; $ names [2] Joe; these ID keys can be used in the script: & PHP =>
Example 1 in this example, the ID key $ names = array ("Peter", "Quagmire", "Joe") is automatically assigned; example 2 in this example, manually assigned ID key: $ names [0] = "Peter"; $ names [1] = "Quagmire"; $ names [2] = "Joe "; you can use these ID keys in the script:
Output of the above code: Quagmire and Joe are Peter's neighbors associates with an array to associate an array. each of its ID keys is associated with a value. It is not the best practice to use a numeric array to store data related to specific named values. By associating arrays, we can use values as keys and assign values to them. Example 1 in this example, we use an array to allocate ages to different people: $ ages = array ("Peter" => 32, "Quagmire" => 30, "Joe" => 34); example 2 This example is the same as example 1, but shows another way to create an array: $ ages ['Peter '] = "32 "; $ ages ['quagmire'] = "30"; $ ages ['job'] = "34"; you can use the ID key in the script:
Output of the above script: Peter is 32 years old. multi-dimensional array in multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on. Example 1 in this example, we create a multidimensional array with an automatically assigned ID key: $ families = array ("Griffin in" => array ("Peter ", "Lois", "Megan"), "Quagmire" => array ("Glenn"), "Brown" => array ("Cleveland", "Loretta ", "Junior"); if this array is output, it should be similar to this: array ([Griffin in] => Array ([0] => Peter [1] => Lois [2] => Megan) [Quagmire] => Array ([0] => Glenn) [Brown] => Array ([0] => Cleveland [1] => Loretta [2] => Junior ))