mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-08-13 14:45:09 +00:00
8 lines
327 B
PHP
8 lines
327 B
PHP
<?php
|
|
$str = '2022-07-15';
|
|
$re = '|^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$|';
|
|
preg_match($re, $str, $matches) or exit('Соответствие не найдено');
|
|
echo 'День: ' . $matches['day'] . '<br />';
|
|
echo 'Месяц: ' . $matches['month'] . '<br />';
|
|
echo 'Год: ' . $matches['year'] . '<br />';
|