<?php
$_POST['pulseCheck'] = "seven + four";
$_POST['solution'] = "12";
$lookup = array_flip(
["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
);
if (!preg_match('~^(10|\d) \+ (10|\d)$~', strtr($_POST['pulseCheck'], $lookup), $matches)
|| $matches[1] + $matches[2] != $_POST['solution']
) {
exit('Something went wrong');
}
preferences:
25.6 ms | 406 KiB | 5 Q