PHP list+explode VS substr+strpos - what is more efficient?

后端 未结 6 1630
迷失自我
迷失自我 2021-01-04 22:24

Sample text:

$text = \'Administration\\Controller\\UserController::Save\';

Task - extract everything before ::

Option 1:

         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 22:32

    Using the time command on Linux. The first one measured in at 0m0.024s and the second at 0m0.011s.

    The second one appears to be faster. I ran it multiple times and the result (bar one time) seemed to be the same.

    EDIT: As suggested, the other user said to run it in a loop of 5000. That completed with the same results.

提交回复
热议问题