build_regex

Creates optimized regular expressions from an array of strings. An optimized regex built using this function will be much faster than a simple regex built using `implode('|', $strings)` --- anywhere from several times to several orders of magnitude faster. However, the time required to build the optimized regex is approximately equal to the time it takes to execute the simple regex. Therefore, it is only worth calling this function if the resulting regex will be used more than once. Because PHP places an upper limit on the allowed length of a regex, very large arrays of $strings may not fit in a single regex. Normally, the excess strings will simply be dropped. However, if the $returnArray parameter is set to true, this function will build as many regexes as necessary to accommodate everything in $strings and return them in an array. You will need to iterate through all elements of the returned array in order to test all possible matches.
Parameters Summary
array $strings
string $delim = NULL
bool $returnArray = false