3v4l.org

run code in 200+ 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 - 7.2.0
aaaaaaaaaa bbbbbbbbbb ccccccccc dddddddddd eeeeeeeeee ffffffffff gggggggggg