RE: [PHP] return

From: Date: Mon, 16 Jul 2001 20:34:24 +0000
Subject: RE: [PHP] return
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58115@lists.php.net to get a copy of this message
On 16-Jul-01 Tyler Longren wrote: > Here's my code: > <? > function expDate($date) { > $month = substr("$date", 0, 2); > $len = strlen($date); > $year = substr("$date", $len-2, $len); > return $month; > return $year; > } > expDate("11/2002"); > print "$month $year"; > ?> > > I know this isn't the correct usage of return, but how to I get the $month > and $year variables so I can print them after I've called the expDate() > function? Currently, nothing is printed to the browser. > return array($month, $year); -- or -- function expDate($date,&$month,&$year) { ... } expDate("11/2002",$month,$year); print ... -- or -- list($month, $year)=explode("/", "11/2002"); Regards, -- Don Read dread@texas.net -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it.

« previous php.general (#58115) next »