In PHP, which is faster: preg_split or explode?

前端 未结 3 2049
不知归路
不知归路 2020-12-06 04:20

This may sound like a stupid question, but: which is faster when using it to extract keywords in a search query in php:

$keyword = preg_split(\'/[\\s]+/\', $         


        
3条回答
  •  暖寄归人
    2020-12-06 05:12

    General rule: if you can do something without regular expressions, do it without them!

    if you want to split string by spaces, explode is way faster.

提交回复
热议问题