我正在循环中检查字符串是否等于另一个字符串.简单的东西.
但是,似乎我一直在添加要检查的字符串,并且有十个不同的字符串,我正在检查每个循环.创建一个要检查的字符串数组更简单,然后执行in_array();但是我想知道哪个会更快地解析并使用更少的系统资源?
排列
$hideme = array(".", "..", "Thumb.db", "index.php", "icons", "index_backup.php",
"style.css", "highlighter.css", "highlighter.js", "users");
if (!in_array($sub, $hideme)) {
Run Code Online (Sandbox Code Playgroud)
String!= String
if ($sub != "." && $sub != ".." ...etc
Run Code Online (Sandbox Code Playgroud)
差异可能微不足道,只是好奇以备将来参考.