Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: str_repeat - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

str_replace" width="11" height="7"/> <str_pad
Last updated: Thu, 31 May 2007

view this page in

str_repeat

(PHP 4, PHP 5)

str_repeat — 文字列を反復する

説明

string str_repeat ( string $input_str, int $multiplier )

inputmultiplier 回を繰り返した文字列を返します。 multiplier は、0 もしくは 0 より大きい必要があります。もし、multiplier が 0 に設定された場合、この関数は空文字を返します。

例 2392. str_repeat()の例

<?php
echo str_repeat("-=", 10);
?>

上の例の出力は以下となります。


-=-=-=-=-=-=-=-=-=-=

     

for, str_pad(), substr_count() も参照ください。



str_replace" width="11" height="7"/> <str_pad
Last updated: Thu, 31 May 2007
 
add a note add a note User Contributed Notes
str_repeat
Alper Kaya
30-Jun-2007 07:09
If you want to hide a part of your password, you can use this code. It's very simple and might be required in your user management panel.

<?php
$password
= "12345abcdef";
$visibleLength = 4; // 4 chars from the beginning

echo substr($password,0,4).str_repeat("*", (strlen($password)-$visibleLength));
?>
15-Sep-2005 11:32
In reply to what Roland Knall wrote:

It is much simpler to use printf() or sprintf() for leading zeros.

<?php
   printf
("%05d<br>\n"1); // Will echo 00001
  
sprintf("%05d<br>\n"1); // Will return 00001
?>
22-Jul-2003 02:45
str_repeat does not repeat symbol with code 0 on some (maybe all?) systems (tested on PHP Version 4.3.2 , FreeBSD 4.8-STABLE i386 ).

Use <pre>
while(strlen($str) < $desired) $str .= chr(0);
</pre> to have string filled with zero-symbols.
dakota at dir dot bg
25-Jun-2002 07:06
Note that the first argument is parsed only once, so it's impossible to do things like this:

echo str_repeat(++$i, 10);

The example will produce 10 times the value of $i+1, and will not do a cycle from $i to $i+10.
bryantSPAMw at geocities dot SPAM dot com
25-Oct-2001 08:16
(For the benefit of those searching the website:)

This is the equivalent of Perl's "x" (repetition) operator, for eg.  str_repeat("blah", 8) in PHP does the same thing as "blah" x 8 in Perl.

str_replace" width="11" height="7"/> <str_pad
Last updated: Thu, 31 May 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites