note 85361 deleted from function.str-pad by danbrown

From: Date: Sat, 02 Jul 2011 18:54:57 +0000
Subject: note 85361 deleted from function.str-pad by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181189@lists.php.net to get a copy of this message
Note Submitter: warmo_at_o2_dot_pl ---- @albert dot serra at camaleongroup dot com You are reinventing the wheel, and your wheel isn't even round. PHP has built-in functions which will accomplish this task and they are called rtrim and ltrim. Look at code below: <pre> <?php $string = 'HOME*******'; echo rtrim($string, '*')."\n"; // HOME $string = '*****HOME'; echo ltrim($string, '*')."\n"; // HOME $string = '*****HOME*****'; echo trim($string, '*')."\n"; // HOME ?> </pre>

« previous php.notes (#181189) next »