note 58465 deleted from language.references.pass by danbrown

From: Date: Thu, 28 Jan 2010 13:19:34 +0000
Subject: note 58465 deleted from language.references.pass by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165419@lists.php.net to get a copy of this message
Note Submitter: ---- <?php function stripzeros($var) { if($var < '10') { $var = substr($var, 1); } return $var; } $day = '04'; $day = stripzeros($day); echo $day."\n"; // 4 -- as expected $day = '04'; stripzeros(&$day); echo $day."\n"; // 4 -- another way to do the above, $day is altered $day = '04'; $newday = stripzeros(&$day); echo $newday."\n"; // 4 echo $day."\n"; // 4 here the reference effectively set $day = $newday $day = '04'; $newday = stripzeros($day); echo $newday."\n"; // 4 echo $day."\n"; // 04 -- with this method you can apply the function to the string and keep the original string ?>

« previous php.notes (#165419) next »