SpreadQuiz/common_func.php
2024-03-05 16:07:47 +01:00

15 lines
486 B
PHP

<?php
function explode_list(string $str) : array {
return explode(",", str_replace(" ", "", $str));
}
function alter_array_contents(array &$a, $add, $remove) {
if (($add !== null) && !array_search($add, $a)) { // if user was not assigned to the corresponding group
$a[] = $add;
}
if (($remove !== null) && (($i = array_search($remove, $a)) !== false)) { // only perform deleting if user is assigned to the passed group
array_splice($a, $i, 1);
}
}