Associated
In PHP, an associated array is an array with string keys rather than numeric keys. An associated array can be created by using the array function and specifying the key-value pairs as arguments. For example:
$student = array(
"first_name" => "John",
"last_name" => "Doe",
"age" => 25
);
This creates an associated array with three elements, each of which has a string key and a value. The keys are "first_name", "last_name", and "age", and the corresponding values are "John", "Doe", and 25, respectively.
You can access the elements of an associated array using the keys as indices. For example:
echo $student["first_name"]; // Outputs "John"
echo $student["last_name"]; // Outputs "Doe"
echo $student["age"]; // Outputs 25
You can also use a loop to iterate over the elements of an associated array and process each element in turn. For example:
foreach ($student as $key => $value) {
echo "$key: $value\n";
}
This would output something like:
first_name: John
last_name: Doe
age: 25