If the Boolean variable true is used as the key name, integer 1 is the key value. if faIse is used as the key name, integer 0 is the key value. If NULL is used as the key name, it is equivalent to NULL characters.
If the Boolean variable true is used as the key name, integer 1 is the key value. if faIse is used as the key name, integer 0 is the key value. If NULL is used as the key name, it is equivalent to using a NULL string, and using a NULL string as the key name will create or overwrite a new one with an empty string as the key value. Note: the array and object cannot be used as the key name. this will cause a warning of Illegal offset type.
In PHP programming, you can assign values to the array by specifying the key name in square brackets to change an existing array. In addition, you can add an empty square brackets ("[]") to the variable name to omit the key name. The basic syntax structure is as follows:
$ Arr [key] = value;
$ Arr [] = value;
// Key can be integer or String
// Value can be any value
If the array does not exist, a new array is created. To change a value, you only need to assign a new value to it. To delete a key name and value pair, use the unset function to release the variable. See Program 2-9.
Example of modifying the array key value in programs 2-9
$ Arr = array (5 => 1, 12 => 2 );
$ Arr [] = 3; // and $ arr [13] = 3; same effect
$ Arr ["x"] = 4; // add a new array element whose key value is x
Unset ($ arr [5]); // delete an array element with a key value of 5 from the array
Unset ($ arr); // delete the entire array
?>
Note:
As described in procedures 2-9, if only the variable name is followed by brackets and the key value name is not specified, the program will take the current maximum integer key value name 12, the new key value name will be the value plus 1. If the current array does not have an integer index, the key value is 0. If the specified key value already exists in the previous declaration, the original value corresponding to the key value name will be overwritten.