3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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'))) . '|';
based on CJuLl
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
123456789| Foo | Déja vu | Déja vu | Déja vu |
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Zc16L on line 3 123456789|PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Zc16L on line 6 Foo |PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Zc16L on line 9 Déja vu |PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Zc16L on line 12 Déja vu |PHP_EOLDéja vu |