1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/13203] Add method for byte by byte comparison to drivers helper

PHPBB3-13203
This commit is contained in:
Marc Alexander
2014-10-22 14:54:22 -05:00
parent e43d1781bf
commit 2b47ef1266
2 changed files with 38 additions and 0 deletions

View File

@@ -142,4 +142,24 @@ class helper
}
return $random;
}
/**
* Compare two strings byte by byte
*
* @param string $string_a The first string
* @param string $string_b The second string
*
* @return bool True if strings are the same, false if not
*/
public function string_compare($string_a, $string_b)
{
$difference = strlen($string_a) != strlen($string_b);
for ($i = 0; $i < strlen($string_a) && $i < strlen($string_b); $i++)
{
$difference |= $string_a[$i] != $string_b[$i];
}
return $difference === 0;
}
}