Change language

PHP Str_repeat () function

|
Syntax :
string str_repeat ($string, $no_of_times)
Parameters : This function takes two parameters, both of which are required to pass.
  • $string : This parameter represents a string to repeat
  • $no_of_times : This parameter represents a number indicating the number of times the $string parameter will be repeated. This parameter must be greater than or equal to zero.
  • Return Value : This function returns a new string composed by repeating the specified $string the specified number of times. If the $no_of_times parameter passed to the function is 0, the function returns an empty string.Examples:
    Input: $str = ’GeeksForGeeks’; print_r (str_repeat ($str, 2)); Output: GeeksForGeeksGeeksForGeeks Input: $str = ’Run’; print_r (str_repeat ($str, 7)); Output: Run Run Run Run Run Run Run
    The following programs illustrate the str_repeat() function in PHP:
    Program - 1 : < tbody>  
    // Input line $str = ’GeeksForGeeks’ ;  
    // Duplicate line print_r ( str_repeat ( $str , 2));  
    ?>
    Output:
    GeeksForGeeksGeeksForGeeks
    Program - 2 : < tbody>  
    // Input line $str = ’Run’ ;  
    // Duplicate line print_r ( str_repeat ( $str , 7));  
    ?>
    Exit:
    Run Run Run Run Run Run Run
    Link :
    http: //php.net/manual/en/function.str-repeat.php

    PHP Str_repeat () function PHP: Questions

    PHP Str_repeat () function repeat: Questions

    Shop

    Best laptop for Fortnite

    $

    Best laptop for Excel

    $

    Best laptop for Solidworks

    $

    Best laptop for Roblox

    $

    Best computer for crypto mining

    $

    Best laptop for Sims 4

    $

    Best laptop for Zoom

    $499

    Best laptop for Minecraft

    $590

    Latest questions

    NUMPYNUMPY

    psycopg2: insert multiple rows with one query

    12 answers

    NUMPYNUMPY

    How to convert Nonetype to int or string?

    12 answers

    NUMPYNUMPY

    How to specify multiple return types using type-hints

    12 answers

    NUMPYNUMPY

    Javascript Error: IPython is not defined in JupyterLab

    12 answers

    Wiki

    Python OpenCV | cv2.putText () method

    numpy.arctan2 () in Python

    Python | os.path.realpath () method

    Python OpenCV | cv2.circle () method

    Python OpenCV cv2.cvtColor () method

    Python - Move item to the end of the list

    time.perf_counter () function in Python

    Check if one list is a subset of another in Python

    Python os.path.join () method