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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
|
<?
// debug-function
function infoArray($String)
{
print '<pre>';
print_r($String);
print '</pre>';
}
// Attachment-Array
$cache =
Array
(
963 => Array
(
550 => Array
(
0 => 550,
1 => 963,
2 => 'test.rar',
3 => 1622,
4 => '',
5 => 1,
6 => 'application/octet-st',
7 => 550
),
548 => Array
(
0 => 548,
1 => 963,
2 => 'Green Sea Turtle.jpg',
3 => 378729,
4 => '1024/768',
5 => 0,
6 => 'image/jpeg'
),
545 => Array
(
0 => 545,
1 => 963,
2 => 'Garden.jpg',
3 => 516424,
4 => '1024/768',
5 => 1,
6=> 'image/jpeg',
7 => 545
)
)
);
$string = " ";
if (0 < count($cache))
{
foreach($cache As $key1 => $arrPostID)
{
foreach($arrPostID As $key2 => $arrAttachID)
{
if (!empty($arrAttachID[7]) AND !empty($arrAttachID[4]))
{
$search[] = "/\[attach\](\d\d\d)\[\/attach\]/esiU";
$replace[] = "'<img src=attachment.php3?thumbnailid=$1 border=1>'";
}elseif (!empty($arrAttachID[7]) AND empty($arrAttachID[4]))
{
$search[] = "/\[attach\](\d\d\d)\[\/attach\]/esiU";
$replace[] = "'<a href=attachment.php3?attachmentid=$1>$arrAttachID[2]</a>'";
}
}
}
}
if (is_array($search) AND is_array($replace) AND !empty($string))
{
ksort($search);
ksort($replace);
// debug-function
infoArray($search);
infoArray($replace);
echo preg_replace($search, $replace, $string);
}
?>
|