Demo For: Using PHP To Delete / Remove Array Keys
Example 1: Removing a key using its position in the arrayFollowing are the original array contents:
Array
(
[0] => apple
[1] => mango
[2] => grapes
[3] => pineapple
)
Following are the array contents AFTER removing the key (1) from array using its position:Array
(
[0] => apple
[2] => grapes
[3] => pineapple
)
Example 2: Removing a key using its specified Key in the arrayFollowing are the original array contents:
Array
(
[1] => apple
[2] => mango
[3] => grapes
[4] => pineapple
)
Following are the array contents AFTER removing the key from array, using key name (3):Array
(
[1] => apple
[2] => mango
[4] => pineapple
)
Example 3: Removing a key using its name in the arrayFollowing are the original array contents:
Array
(
[Fruit 1] => apple
[Fruit 2] => mango
[Fruit 3] => grapes
[Fruit 4] => pineapple
)
Following are the array contents AFTER removing the key from array, using key name (Fruit 4):Array
(
[Fruit 1] => apple
[Fruit 2] => mango
[Fruit 3] => grapes
)