I have the following code on my index.php file
<?php
$string = $_GET['string'];
$month = '';
$day = '';
?>
If string is like "apr12" or "12apr", then $month should be "apr" and $day should be "12" else both $month & $day should be blank.
I have the following code on my index.php file
<?php
$string = $_GET['string'];
$month = '';
$day = '';
?>
If string is like "apr12" or "12apr", then $month should be "apr" and $day should be "12" else both $month & $day should be blank.
You can use the fact that day is only numbers and month is only chars, so it may look like this:
$string = $_GET['string'];
$month = strtolower(preg_replace('/[^a-z]+/i','',$string));
$day = preg_replace('/[^0-9]+/','',$string);
if (!in_array($month, ['jan'/* ... and other valid values */], true)) {
$month = '';
}
if ($day === '' || (int)$day < 1 || (int)$day > 31) {
$day = '';
}
// Then validate your input further