分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

PHP之string之str_repeat()函数使用

发布时间:2023-09-06 01:44责任编辑:熊小新关键词:PHP

str_repeat

  • (PHP 4, PHP 5, PHP 7)
  • str_repeat — Repeat a string
  • str_repeat — 重复一个字符串

Description

string str_repeat ( string $input , int $multiplier )//Returns input repeated multiplier times.//返回 input 重复 multiplier 次后的结果。

Parameters

input

  • The string to be repeated.
  • 待操作的字符串。

multiplier

  • Number of time the input string should be repeated.
  • input 被重复的次数。

  • multiplier has to be greater than or equal to 0. If the multiplier is set to 0, the function will return an empty string.
  • multiplier 必须大于等于 0。如果 multiplier 被设置为 0,函数返回空字符串。

Return Values

  • Returns the repeated string.
  • 返回重复后的字符串。

Examples

<?php/** * Created by PhpStorm. * User: zhangrongxiang * Date: 2018/2/20 * Time: 下午11:50 *///------------------------------echo str_repeat( "-", 30 ) . PHP_EOL;//******************************echo str_repeat( "*", 30 ) . 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( "°~", 35 );echo strlen( $my_head ) . PHP_EOL; // 105echo mb_strlen( $my_head, 'UTF-8' ) . PHP_EOL; // 70echo 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之string之str_repeat()函数使用

原文地址:https://www.cnblogs.com/zhangrxiang/p/8519429.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved