|
1 members (Russ),
10,950
guests, and
1,516
robots. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
S |
M |
T |
W |
T |
F |
S |
|
|
|
1
|
2
|
3
|
4
|
5
|
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
|
27
|
28
|
29
|
30
|
31
|
|
|
|
|
This is another custom island. This one could be used for ads. This spot is one of the best places for ads on your site to be placed. This can be enabled/disabled on a per forum basis.
|
|
|
|
Joined: Dec 1999
Posts: 30,868
Master Elite Member
|
Str_Glob_NoCase() - Creating a case-insensitive glob array for use in glob()This function is part of a solution when you want to use the PHP glob() function to return a list of files with a certain suffix, but you want the glob to perform matching in a case-insensitive manner. Originally, I wrote a function that returns this type of pattern: Input (string array): ["jpg","png"] Output: "{[jJ][pP][gG],[pP][nN][gG]}" On Linux, this works fine, but on Windows, the glob() function (using the GLOB_BRACE flag) will not handle this correctly (see PHP bug 69628). As a result, we have to take this new approach. Be warned, however, that PHP limits the glob expression to 260 characters, so trying to glob more than a few file extensions will quickly exhaust this limitation.
function Str_Glob_NoCase ($Suffix) {
$r = array();
if (strlen($Suffix) === 0) return $r;
$Mask = str_repeat('0', strlen($Suffix));
$Suffix = strtolower($Suffix);
$r[] = $Suffix;
while (true) {
$x = base_convert($Mask, 2, 10);
$x++;
$Mask = str_pad(base_convert($x, 10, 2), strlen($Mask), "0", STR_PAD_LEFT);
$xSuffix = $Suffix;
for ($i = 0; $i < strlen($Mask); $i++) {
if ($Mask[$i] == '1') $xSuffix[$i] = strtoupper($xSuffix[$i]);
}
$r[] = $xSuffix;
if (strpos($Mask, "0") === false) break;
}
return $r;
}
|
|
|
|
|