LtrimDigits.php 490 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * @package koseven/Codebench
  4. * @category Tests
  5. * @author Geert De Deckere <geert@idoe.be>
  6. */
  7. class Bench_LtrimDigits extends Codebench {
  8. public $description = 'Chopping off leading digits: regex vs ltrim.';
  9. public $loops = 100000;
  10. public $subjects = [
  11. '123digits',
  12. 'no-digits',
  13. ];
  14. public function bench_regex($subject)
  15. {
  16. return preg_replace('/^\d+/', '', $subject);
  17. }
  18. public function bench_ltrim($subject)
  19. {
  20. return ltrim($subject, '0..9');
  21. }
  22. }