$new_arr = array();
foreach ($arr as $date => $sessions) {
$new_key = 0;
foreach ($arr as $date2 => $sessions2) {
if($sessions2 == $sessions){
//$new_arr[$date] = $sessions;
$new_key = preg_split("/-/", $new_key)[0];
$new_key = "$date-$date2";
unset($arr[$date2]);
}
}
if($new_key!=0) $new_arr[$new_key] = $sessions;
}
function field_is_unique(inputElement){
var xhr = new XMLHttpRequest();
xhr.open("GET", "modules/php/check_field_is_unique.php?" + inputElement.dataset.type + "=" + encodeURIComponent(inputElement.value), true);
xhr.send();
xhr.addEventListener("loadend", function() {
var field_is_unique = JSON.parse(this.responseText).field_is_unique;
function show_message(inputElement, error_msg){
inputElement.previousElementSibling.innerHTML = error_msg;
inputElement.style.borderColor = "red";
}
if(!field_is_unique) show_message(inputElement, "Логин занят");
window[inputElement.dataset.type + "_is_unique"] = field_is_unique;
});
}
set_error_handler(function($errno, $error_message, $err_file, $errline){
echo "<div class='error_message'>Произошла ошибка уровня $errno. Попробуйте заглянуть позже.</div>";
if (($errno == E_USER_ERROR) || ($errno == E_ERROR)) {
echo "<p>Fatal error. Program ending.</p>";
exit;
}
echo "<hr/>";
return false;
});