1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <?php
$array = array(
'<textarea>',
'<textarea />',
'<textarea cols="60" />',
'<textarea cols="60" rows="60">',
'<textarea required="true">',
'<textarea cols="60" required="true" rows="60">',
'<textarea cols="60" required="true">',
'<textarea required="true" rows="60">',
'<textarea required="false">',
'<textarea cols="60" required="false" rows="60">',
'<textarea cols="60" required="false">',
'<textarea required="false" rows="60">',
'<textarea is_required="true">',
'<textarea cols="60" is_required="true" rows="60">',
'<textarea cols="60" is_required="true">',
'<textarea is_required="true" rows="60">'
);
header('Content-type: text/plain');
foreach ($array as $v) {
printf("$v : %s".PHP_EOL, preg_match('/<textarea(?:(?!\brequired="true")[^>])*>/Uis', $v) ? 'OK' : 'KO');
}
echo str_repeat('-', 60) . PHP_EOL;
if (preg_match_all('/<textarea(?:(?!\brequired="true")[^>])*>/Uis', implode(PHP_EOL, $array), $matches, PREG_SET_ORDER)) {
foreach ($matches as $m) {
echo $m[0] . PHP_EOL;
}
} |
Partager