开发者

Checking the element whether it is in array and getting remaining values of array

开发者 https://www.devze.com 2023-02-14 22:50 出处:网络
I have an array(1,3,5,7,10) and an variable containing value say a=1 Now i want to get the result 开发者_Go百科as array(3,5,7,10) ie. getting the values other than that variable valuearray_diff($origi

I have an array(1,3,5,7,10) and an variable containing value say a=1 Now i want to get the result 开发者_Go百科as array(3,5,7,10) ie. getting the values other than that variable value


array_diff($original_array, array($a));


use array_diff: http://php.net/manual/en/function.array-diff.php

$arr1 = array(1,3,5,7,10)
$a = 1
$arr2 = array_diff($arr1, array($a))
0

精彩评论

暂无评论...
验证码 换一张
取 消