gwolgamott Posted February 9, 2010 Share Posted February 9, 2010 How do I make that piece of code more efficient, for lack of a better word I guess? Meaning so I can store a chunk of exceptions in an array then have it just check $element against any one of the array elements. I'm pretty sure I've done this before but for the life of me can not think of it and I must be searching for the wrong thing to find what I am looking for elsewhere... elseif ($element!= "." && $element!= ".." && $element!= "struct.php" && $element!= "index.php" && $element!= "index.htm" && $element!= "index.html") { //do whatever here } Link to comment https://forums.phpfreaks.com/topic/191479-exception-elseif-statement-using-array-elements-instead-of-a-string/ Share on other sites More sharing options...
aeroswat Posted February 9, 2010 Share Posted February 9, 2010 How do I make that piece of code more efficient, for lack of a better word I guess? Meaning so I can store a chunk of exceptions in an array then have it just check $element against any one of the array elements. I'm pretty sure I've done this before but for the life of me can not think of it and I must be searching for the wrong thing to find what I am looking for elsewhere... elseif ($element!= "." && $element!= ".." && $element!= "struct.php" && $element!= "index.php" && $element!= "index.htm" && $element!= "index.html") { //do whatever here } Checking to see if $element is one of those? So those strings would be in the array? If so you could use array_intersect http://us2.php.net/array_intersect Link to comment https://forums.phpfreaks.com/topic/191479-exception-elseif-statement-using-array-elements-instead-of-a-string/#findComment-1009403 Share on other sites More sharing options...
gwolgamott Posted February 9, 2010 Author Share Posted February 9, 2010 Thanks, exactly what I wanted. Link to comment https://forums.phpfreaks.com/topic/191479-exception-elseif-statement-using-array-elements-instead-of-a-string/#findComment-1009418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.