Skip to content

Commit ff9e6ec

Browse files
authored
Merge pull request #11 from hexmode/substr-bug
mb_substr() treats $length differently than substr()
2 parents bcac3b9 + 1d508ed commit ff9e6ec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/TableFormatter.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,12 @@ protected function substr($string, $start = 0, $length = null)
273273
if (function_exists('mb_substr')) {
274274
return mb_substr($string, $start, $length);
275275
} else {
276-
return substr($string, $start, $length);
276+
// mb_substr() treats $length differently than substr()
277+
if ($length) {
278+
return substr($string, $start, $length);
279+
} else {
280+
return substr($string, $start);
281+
}
277282
}
278283
}
279284

0 commit comments

Comments
 (0)