note 85361 added to function.str-pad
| From: | warmo_at_o2_dot_pl at osu1 dot php dot net | Date: | Wed, 27 Aug 2008 11:56:09 +0000 |
| Subject: | note 85361 added to function.str-pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143865@lists.php.net to get a copy of this message | ||
@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>
----
Server IP: 82.177.164.100
Probable Submitter: 62.121.124.204
----
Manual Page -- http://www.php.net/manual/en/function.str-pad.php
Edit -- https://master.php.net/note/edit/85361
Del: integrated -- https://master.php.net/note/delete/85361/integrated
Del: useless -- https://master.php.net/note/delete/85361/useless
Del: bad code -- https://master.php.net/note/delete/85361/bad+code
Del: spam -- https://master.php.net/note/delete/85361/spam
Del: non-english -- https://master.php.net/note/delete/85361/non-english
Del: in docs -- https://master.php.net/note/delete/85361/in+docs
Del: other reasons-- https://master.php.net/note/delete/85361
Reject -- https://master.php.net/note/reject/85361
Search -- https://master.php.net/manage/user-notes.php