3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $value = 'Y-100;Y-10'; $arrvalidrules = explode(';', $value); // On vérifie qu'il n'y bien que deux valeurs. if (count($arrvalidrules) == 2) { $arrvarlabels = array('intyearstart', 'intyearend'); foreach ($arrvarlabels as $key => $val) { if ($arrvalidrules[$key]!='') { if (is_numeric($arrvalidrules[$key])) { ${$arrvarlabels} = intval($arrvalidrules[$key]); } else if (strpos($arrvalidrules[$key], 'Y') === 0) { ${$arrvarlabels} = date('Y'); if (($intsignpos = strpos($arrvalidrules[$key], '+')) !== false) { ${$arrvarlabels} += intval(trim(substr($arrvalidrules[$key], $intsignpos+1))); } else if (($intsignpos = strpos($arrvalidrules[$key], '-')) !== false) { ${$arrvarlabels} -= intval(trim(substr($arrvalidrules[$key], $intsignpos+1))); } } else { ${$arrvarlabels} = 0; } } else { ${$arrvarlabels} = 0; } } } echo 'Date : '.$intyearstart.' - '.$intyearend; echo 'Date : '.$intyearstart.' - '.$intyearend;
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Array to string conversion in /in/3Ho9r on line 21 Notice: Array to string conversion in /in/3Ho9r on line 29 Notice: Array to string conversion in /in/3Ho9r on line 21 Notice: Array to string conversion in /in/3Ho9r on line 29 Notice: Undefined variable: intyearstart in /in/3Ho9r on line 44 Notice: Undefined variable: intyearend in /in/3Ho9r on line 44 Date : - Notice: Undefined variable: intyearstart in /in/3Ho9r on line 46 Notice: Undefined variable: intyearend in /in/3Ho9r on line 46 Date : -
Output for 4.3.0 - 5.0.3
Notice: Array to string conversion in /in/3Ho9r on line 21 Notice: Array to string conversion in /in/3Ho9r on line 29 Notice: Array to string conversion in /in/3Ho9r on line 21 Notice: Array to string conversion in /in/3Ho9r on line 29 Notice: Undefined variable: intyearstart in /in/3Ho9r on line 44 Notice: Undefined variable: intyearend in /in/3Ho9r on line 44 Date : - Notice: Undefined variable: intyearstart in /in/3Ho9r on line 46 Notice: Undefined variable: intyearend in /in/3Ho9r on line 46 Date : -