What wrong in this code?

HQCoder

Member
Hi every one!!!
Code:
<?php

$TheWhiteList = Array
('http://facebook.com',
    'google.com',
       'facebook.com',
    'xenforo.com',
);

$message ='test test tes tes [URL=http://facebook.com]http://facebook.com[/URL]
[URL]http://facebook.com[/URL]
[URL]http://facebook.com[/URL]
[URL]http://facebook.com[/URL]
[URL]http://facebook.com[/URL]';
$string = '';
        if(!empty($TheWhiteList))
        {
            foreach ($TheWhiteList as $value)
            {
                if(!empty($string))
                {
                    $string .= '|';
                }
                $string .=preg_quote($value);
            }

            $pattern = '#\[url=[\'\"]('.$string.')[\'\"]\].*\[\/url\]#imsU';

            $replace = null;

            $message = @preg_replace($pattern, $replace, $message);
        }
print_r($message);


?>

i write this code to replace $TheWhiteList to null string in message and show it to screen.
but it not work. Can you tell me where I was wrong?
 
Last edited:
Top Bottom