String Repeat – A PHP Tip for Python Programmers

Those of us who use Python have to some extent been spoiled by its comparitively simple syntax. For example, in Python, you can do this: print(“Hello ” * 3) and get the output Hello Hello Hello which makes sense, right? In PHP, the equivalent is: <?php echo str_repeat(“Hello “, 3); ?> It’s great that PHP has this function, but it’s not as intuitive, to my mind.