The Str_repeat () function of the PHP string is used

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.