Skip to content

Commit

Permalink
Use foreach instead of for
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Aug 7, 2013
1 parent 2c17db1 commit 865de70
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libraries/Util.class.php
Expand Up @@ -4051,12 +4051,12 @@ public static function getFirstOccurringRegularExpression($regex_array, $query)
$minimum_first_occurence_index = null;
$regex = null;

for ($i = 0; $i < count($regex_array); $i++) {
if (preg_match($regex_array[$i], $query, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($regex_array as $test_regex) {
if (preg_match($test_regex, $query, $matches, PREG_OFFSET_CAPTURE)) {
if (is_null($minimum_first_occurence_index)
|| ($matches[0][1] < $minimum_first_occurence_index)
) {
$regex = $regex_array[$i];
$regex = $test_regex;
$minimum_first_occurence_index = $matches[0][1];
}
}
Expand Down

0 comments on commit 865de70

Please sign in to comment.