It says that it "expects parameter 1 to be string". So i guess you cant have an array in preg_match. But what should I use instead? Thanks
$config['forbidden_names'] = array('admin', 'moderator', 'hoster');
if (preg_match($config['forbidden_names'], $string)) echo "Forbidden name!";
edit: in_array maybe. lol. im stupid
if (in_array($string, $config['forbidden_names']))
echo "Forbidden name!";
Or if you must use regex:
if (preg_match('/^(?:admin|moderator|hoster)$/', $string))
echo "Forbidden name!";
try this
if (preg_match('/(admin|moderator|hoster)/i', $string)) echo "Forbidden name!";
btw i would rather add to your roles model/table a new column/settings var that manages stuff user is allowed to add. this looks insecure to me.
Change your second line to:
if (in_array($string, $config['forbidden_names'])) echo "Forbidden name!";
preg_match uses a regular expression, you should stay away from it unless you really need to search through a regex string, because it is slow.