note 36398 added to function.split

From: Date: Wed, 08 Oct 2003 16:26:55 +0000
Subject: note 36398 added to function.split
Groups: php.notes 
Request: Send a blank email to php-notes+get-58056@lists.php.net to get a copy of this message
php4.3.0 strange things happen with split this didn't work $vontag $vonmonat were empty strings <?php function ckdate($fromdate="01.01", $todate="31.12") { $nowyear = date("Y"); list ($vontag , $vonmonat) = split ('.' , $fromdate); // << bad $vondatum = "$nowyear-$vonmonat-$vontag"; list ($bistag , $bismonat) = split ('.' , $todate); // << bad $bisdatum = "$nowyear-$bismonat-$bistag"; $von = strtotime($vondatum); $bis = strtotime($bisdatum); $now = time(); if (($now <= $bis) and ($now >= $von)) { return TRUE; } else { return FALSE; } } ?> however this one worked perfectly <?php function ckdate($fromdate="01.01", $todate="31.12") { $nowyear = date("Y"); list ($vontag , $vonmonat) = split ('[.]' , $fromdate); // << good $vondatum = "$nowyear-$vonmonat-$vontag"; list ($bistag , $bismonat) = split ('[.]' , $todate); // << good $bisdatum = "$nowyear-$bismonat-$bistag"; $von = strtotime($vondatum); $bis = strtotime($bisdatum); $now = time(); if (($now <= $bis) and ($now >= $von)) { return TRUE; } else { return FALSE; } } ?> btw this fn checks if $now if between $fromdate and $todate use it if you like ---- Manual Page -- http://www.php.net/manual/en/function.split.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36398 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36398&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36398&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58056) next »