Repeat String for Given Number of Times using PHP

str_repeat function

<?php

$text = '+-';
$n = 5;
$result = str_repeat($text, $n);

echo $result; // +-+-+-+-+-

Leave a Comment

Cancel reply

Your email address will not be published.