The php array is divided into array values and array keys. The following small series will summarize the common operations for array values in php: for more information about php tutorials, such as adding values to an array, determining values in an array, and deleting specific array values, see. Php enthusiasts share their development experiences. php deletes a specific array value var_dump ($ context [
The php array is divided into array values and array keys. The following small series will summarize the common operations for array values in php: for more information about php tutorials, such as adding values to an array, determining values in an array, and deleting specific array values, see. Php enthusiasts share their development experiences. php deletes the specified array value var_dump ($ context ['
The php array is divided into array values and array keys. The following small series will summarize the common operations for array values in php: for more information about php tutorials, such as adding values to an array, determining values in an array, and deleting specific array values, see. Php enthusiasts share their development experiences
Php deletes a specific array value
Var_dump ($ context ['linktree']);
The
Array (3 ){
[0] =>
Array (2 ){
["Url"] =>
String (52) "http: // 127.0.0.1/testforum.cityofsteam.com/index.php"
["Name"] =>
String (28) "City of Steam Official Forum"
}
[1] =>
Array (2 ){
["Url"] =>
String (55) "http: // 127.0.0.1/testforum.cityofsteam.com/index.php?c1 ″
["Name"] =>
String (28) "City of Steam Official Forum"
}
[2] =>
Array (2 ){
["Url"] =>
String (62) "http: // 127.0.0.1/testforum.cityofsteam.com/index.php? Board = 4.0 ″
["Name"] =>
String (12) "Announcement"
}
}
I want to remove the middle one.
Use: unset ($ context ['linktree'] ['1']);
Array (2 ){
[0] =>
Array (2 ){
["Url"] =>
String (52) "http: // 127.0.0.1/testforum.cityofsteam.com/index.php"
["Name"] =>
String (28) "City of Steam Official Forum"
}
[2] =>
Array (2 ){
["Url"] =>
String (62) "http: // 127.0.0.1/testforum.cityofsteam.com/index.php? Board = 4.0 ″
["Name"] =>
String (12) "Announcement"
}
}
One [1] is missing.
Let the Middle 1 be automatically numbered:
Array ([0] => apple [1] => banana [3] => dog)
Function array_remove (& $ arr, $ offset)
{
Array_splice ($ arr, $ offset, 1 );
}
$ Arr = array ('apple', 'Banana ', 'cat', 'Dog ');
Array_remove ($ arr, 2 );
Print_r ($ arr );
?>
After testing, we can know that the element 2 is actually deleted and the index is re-created.
Original article address: added the delete search operation method for php array values. Thank you for sharing it with the original author.