function updateRights($gid, $rank, $ids) { query("delete from group_rights where gid = {$gid} and rank = {$rank}"); $rights = selectsql("select rid from group_rights\n where gid = {$gid} and rank >= {$rank}"); for ($i = 0; $i < count($ids); $i++) { if (searchArray("rid", $ids[$i], $rights)) { query("update group_rights\n set rank = {$rank} where rid = " . $ids[$i] . " AND gid = {$gid}"); } else { query("insert into group_rights(rank,rid,gid)\n values ({$rank}," . $ids[$i] . ",{$gid})"); } } }
return "TRUE" . PHP_EOL; } else { return "FALSE" . PHP_EOL; } } function compareArray($names, $compare) { $match = 0; foreach ($names as $name) { if (array_search($name, $compare) !== false) { $match++; } } return $match; } function combine_arrays($names, $compare) { $newArray = []; foreach ($names as $index => $name) { if (array_search($name, $compare) !== false) { array_push($newArray, $name); } else { array_push($newArray, $name, $compare[$index]); } } return $newArray; } print_r(combine_arrays($names, $compare)); echo searchArray('Dana', $names) . PHP_EOL; echo searchArray($query, $names) . PHP_EOL; echo compareArray($names, $compare) . PHP_EOL;