PHP 删除数组指定元素

根据值删除数组元素

<?php
$fields = [1, 2, 3, 4, 5];
$key = array_search('4', $fields);
unset($fields[$key]);

关联数组根据 key 删除数组元素

<?php
$fields = ['key1' => 1, 'key2' => 2, 'key3' => 3];
unset($fields['key2']);
原文地址:https://www.cnblogs.com/ryanzheng/p/13273330.html