Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2. $text="testing:this is a test";
  3.  
  4. $text="testing:this is a test";
  5.  
  6. $start=microtime(1);
  7. for ($c=0;$c!=100000;$c++) find1($text);
  8. $time1=microtime(1)-$start;
  9.  
  10. $start=microtime(1);
  11. for ($c=0;$c!=100000;$c++) find2($text);
  12. $time2=microtime(1)-$start;
  13.  
  14. echo "find1 = $time1\n";
  15. echo "find2 = $time2\n";
  16.  
  17. function find1($text,$separator=':') {
  18.         $after=substr($text,strpos($text,$separator)+1);
  19.         return $after;
  20. }
  21.  
  22. function find2($text,$separator=':') {
  23.         $tmp=explode($separator,$text);
  24.         return $tmp[1];
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement