Re: Problems with split

From: Date: Tue, 14 Aug 2001 01:00:55 +0000
Subject: Re: Problems with split
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-62544@lists.php.net to get a copy of this message
In article <20010813205117.B888@tangledhelix.com>, dan@tangledhelix.com (Dan Lowe) wrote: > > $invdate = "14.8.2001"; > > echo "$invdate\n"; > > list($day, $month, $year) = split(".", $invdate); > > echo "$year-$month-$day"; > > --- > > Somehow, the second echo outputs only "--" as it should be > > "2001-8-14". > > Any idea why this happen and how this could be avoided? > > Change the third line to read: > > list($day, $month, $year) = split("\.", $invdate); Or change: split(".", $invdate) To: explode(".", $invdate) Since you aren't using the regex overhead anyway. -- CC

« previous php.general (#62544) next »