PHP =
Example 1 in this example, the ID key is automatically assigned: $names = Array ("Peter", "Quagmire", "Joe"), example 2 in this example, we manually assign the ID key: $names [0] = "Peter"; $names [1] = "Qu Agmire "; $names [2] =" Joe "; you can use these ID keys in your script:
Output from the above code: Quagmire and Joe are Peter's neighbors associative array, which each ID key associates with a value. Using numeric arrays is not the best practice when storing data about a specific named value. With associative arrays, we can use values as keys and assign values to them. Example 1 in this example, we use an array to assign age to different people: $ages = Array ("Peter" =>32, "quagmire" =>30, "Joe" =>34); Example 2 This example is the same as Example 1, But it shows another way to create an array: $ages [' Peter '] = "All", $ages [' quagmire '] = "34", $ages [' Joe '] = "+"; you can use the ID key in the script:
Output from the above script: Peter is years old. Multidimensional arrays in multidimensional arrays, each element in the primary array is also an array. Each element in a sub-array can also be an array, and so on. Example 1 in this example, we create a multidimensional array with an auto-assigned ID key: $families = Array ("Griffin" =>array ("Peter", "Lois", "Megan"), "quagmire" =& Gt;array ("Glenn"), "Brown" =>array ("Cleveland", "Loretta", "Junior")); If you output this array, it should look like this: Array ([Griffin] = > Array ([0] = Peter [1] = Lois [2] = Megan) [quagmire] + array ([0] = = Glenn) [Brown] =&G T Array ([0] = Cleveland [1] = Loretta [2] = Junior))