Content model:
- If the element has a label attribute and a value attribute: Nothing.
- If the element has a label attribute but no value attribute: Text.
- If the element has no label attribute: and is not a child of a datalist element: Text that is not inter-element white space.
- If the element has no label attribute and is a child of a datalist element: Text.
function check(str, bracketsConfig) {
let bconf = bracketsConfig.reduce(
(acc, val) => {
acc[val[0]] = val[1];
acc[val[1]] = null;
return acc;
},
{}
);
let stack = [];
for (let i = 0; i < str.length; i++) {
let char = str[i];
if (bconf[char] === null) {
if (stack.pop() !== char) {
return false;
}
} else if (bconf[char] !== undefined) {
stack.push(bconf[char]);
}
}
if (stack.length !== 0) {
return false;
}
return true;
}
<?php
session_start();
require_once "connect.php";
$stmt = mysqli_prepare($connect, "SELECT `Password` FROM `users` WHERE `Email` = ?");
mysqli_stmt_bind_param('s', $_POST['Email']);
mysqli_stmt_bind_result($hash);
mysqli_stmt_execute($stmt);
if (mysqli_stmt_fetch($stmt) && password_verify($_POST['password'], $hash)) {
echo 'Logged';
}
}
function getFreeInterval($intervals, $startTime, $endTime)
{
$result = [];
$ok = false;
foreach($intervals as $key => $interval){
list($start, $end) = explode('-', $interval);
if ($startTime >= $start && $endTime <= $end) {
$ok = true;
if ($startTime > $start) {
$result[] = "{$start}-{$startTime}";
}
if ($endTime < $end) {
$result[] = "{$endTime}-{$end}";
}
} else {
$result[] = $interval;
}
}
return [
$ok,
$result
];
}
$intervals = [
'09:30:00-13:15:00',
'14:00:00-17:00:00'
];
list($ok, $result) = getFreeInterval($intervals, '09:30:00', '10:15:00');
var_dump($ok, $result);
// bool(true)
// array(2) {
// [0]=> string(17) "10:15:00-13:15:00"
// [1]=> string(17) "14:00:00-17:00:00"
// }