functions.inc.php

- new function remove_from_array()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1343 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent 4e5bd47183
commit b0277b6c03

@ -1262,6 +1262,23 @@ function hex2bin ($str) {
} }
return $nstr; return $nstr;
} }
/*
* remove item $item from array $array
*/
function remove_from_array($array, $item) {
# array_diff might be faster, but doesn't provide an easy way to know if the value was found or not
# return array_diff($array, array($item));
$ret = array_search($item, $array);
if ($ret === false) {
$found = 0;
} else {
$found = 1;
unset ($array[$ret]);
}
return array($found, $array);
}
/**/ } /**/ }
function to64 ($v, $n) { function to64 ($v, $n) {

Loading…
Cancel
Save