3v4l.org

run code in 300+ PHP versions simultaneously
<?php $len = 9; echo implode('', array_keys(array_fill(1, $len, ''))) . '|' . PHP_EOL; // ASCI string echo str_pad('Foo', $len) . '|' . PHP_EOL; // str_pad with utf-8 string echo str_pad('Déja vu', $len) . '|' . PHP_EOL; // str_padding a decoded string then re-encode the string echo utf8_encode(str_pad(utf8_decode('Déja vu'), $len)) . '|' . PHP_EOL; // using str_repeat and Helper::strlen echo 'Déja vu'.str_repeat(' ', $len - mb_strwidth('Déja vu', mb_detect_encoding('Déja vu'))) . '|';

preferences:
67.14 ms | 402 KiB | 5 Q