note 84485 modified in function.str-pad by danbrown
| From: | danbrown@php.net | Date: | Thu, 17 Jul 2008 14:20:53 +0000 |
| Subject: | note 84485 modified in function.str-pad by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141625@lists.php.net to get a copy of this message | ||
If you want to pad strings to a certain length in a REALLY performant way then you should use a
binary OR instead.
For example:
<? $padded = "Short" | " "; ?>
This gives the same result as:
<? $padded = str_pad("Short", 10); ?>
On my machine the first version is about 250% faster and provides the exact same result.
--was--
If you want to pad strings to a certain length in a REALLY performant way then you should use a
binary OR instead.
For example:
<? $padded = "Short" | " "; ?>
This gives the same result as:
<? $padded = str_pad("Short", 10); ?>
On my machine the second version is about 250% faster and provides the exact same result.
http://php.net/manual/en/function.str-pad.php