3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function subString($str, $limit) { $char = ''; if($limit >= strlen($str)) $limit = strlen($str); for ($i = 0; $i < $limit; $i++) { $char .= $str[$i]; } return $char; } $string = 'aaaaaaaaaa bbbbbbbbbb ccccccccc dddddddddd eeeeeeeeee ffffffffff gggggggggg'; print subString($string, 100);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
aaaaaaaaaa bbbbbbbbbb ccccccccc dddddddddd eeeeeeeeee ffffffffff gggggggggg