Re: Better method than stristr

From: Date: Tue, 30 May 2006 02:15:25 +0000
Subject: Re: Better method than stristr
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237054@lists.php.net to get a copy of this message
On Mon, May 29, 2006 2:27 pm, Steven Osborn wrote: > Can someone please advise a faster solution to do what I'm doing > below? All I need to be able to do is determine if any of the > strings in the array are contained in $q. The method I have works, > but I'm sure its not the most efficient way to do it. > > $dirtyWord = array("UNION","LOAD_FILE","LOAD DATA > INFILE","LOAD > FILE","BENCHMARK","INTO OUTFILE"); For starters, you should probably have your MySQL user constrained from doing those things, rather than trying to hack this in PHP. Next, what makes you think this is "slow"? I should not be particularly slow as you are iterating over only 6 items in a PHP array. I suppose you could try array_walk or something, but it's probably not going to be significantly different, based on what we see here... -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#237054) next »