3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $value = 'Y+10;'; $arrvalidrules = explode(';', $value); // On vérifie qu'il n'y bien que deux valeurs. if (count($arrvalidrules) == 2) { $intyearend = null; if ($arrvalidrules[0]!='') { if (is_numeric($arrvalidrules[0])) { $intyearstart=intval($arrvalidrules[0]); } else if (strpos($arrvalidrules[0], 'Y') === 0) { $intyearstart = date('Y'); if (($intsignpos = strpos($arrvalidrules[0], '+')) !== false) { $intyearstart += (int) (trim(substr($arrvalidrules[0], $intsignpos))); } else if (($intsignpos = strpos($arrvalidrules[0], '-')) !== false) { $intyearstart -= (int) (trim(substr($arrvalidrules[0], $intsignpos))); } } else { $intyearstart = false; } } else { $intyearstart = 0; } } echo 'Date : '.$intyearstart.' - '.$intyearend;
Output for 4.3.0 - 7.1.0
Date : 2023 -