Str_repeat
- (PHP 4, PHP 5, PHP 7)
- Str_repeat-repeat a string
- str_repeat-repeating a string
Description
str_repeat($input,$multiplier)//Returns input repeated multiplier times.//返回 input 重复 multiplier 次后的结果。
Parametersinput
- The string to is repeated.
- The string to be manipulated.
Multiplier
- Number of time the input string should be repeated.
The number of times that input was repeated.
- Multiplier have to is greater than or equal to 0. If the multiplier is set to 0, the function would return an empty string.
Multiplier must be greater than or equal to 0. If multiplier is set to 0, the function returns an empty string.
Return Values
- Returns the repeated string.
- Returns the repeating string.
Examples
<?php/*** Created by Phpstorm.* User:zhangrongxiang* DATE:2018/2/20* Time: PM 11:50 *///------------------------------Echo str_repeat( "-", - ).Php_eol;//******************************Echo str_repeat( "*", - ).Php_eol;////////////////////////////////////////////////////////////////$input=' Bar ';$multiplier=5;$separator=',';//bar,bar,bar,bar,barEcho implode( $separator, Array_fill( 0, $multiplier, $input ) ).Php_eol;//?,?,?Echo implode( ',', Array_fill( 0, 3, '?' ) ).Php_eol;$my _head=str_repeat( "°~", * );Echo strlen( $my _head ).Php_eol; //Echo Mb_strlen( $my _head, ' UTF-8 ' ).Php_eol; //Echo strlen( "°" ).Php_eol;//2Echo strlen( "~" ).Php_eol;//1//°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~°~Echo $my _head.Php_eol;
See
- http://php.net/manual/zh/function.str_repeat.php
All rights reserved
PHP str_repeat () function using the string