Removing a value from a PHP Array

前端 未结 3 841
逝去的感伤
逝去的感伤 2021-01-14 19:39

Using PHP I\'m trying to remove an element from an array based on the value of the element.

For example with the following array:

Array
(
    [671] =         


        
3条回答
  •  长发绾君心
    2021-01-14 20:34

    You can use:

    array_walk($your_array, function(&$sub, $key, $remove_value) {
        $sub = array_diff($sub, array($remove_value));
    }, 100);
    

提交回复
热议问题