0
    function validate_font_family($font_family, &$error_message)
    {
        $valid_match1 = '"Times New Roman",Georgia,Serif';
        $valid_match2 = '"Arial",Georgia,Serif';
        if(preg_match($valid_match1, $font_family) || preg_match($valid_match2, $font_family))
        {
            return true;
        }

        $error_message = "Invalid font family(" . $font_family . ").  Must be either ";
        $error_message .= $valid_match1 . " or " . $valid_match2;
        return false;
    }

The code is supposed to take a string, and if it is either of the following...

  • "Times New Roman",Georgia,Serif
  • "Arial",Georgia,Serif

it should return true. Otherwise, false.

I get the following error.

Warning: preg_match() [function.preg-match]: Unknown modifier ',' in C:\xampp\htdocs\MrLyons2\change_css.php on line 26

Warning: preg_match() [function.preg-match]: Unknown modifier ',' in C:\xampp\htdocs\MrLyons2\change_css.php on line 26

The comma in question appears to be the one right beforGeorgia, so I guess I need to escape those double quotes or something like that?

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by VernonDozier
0

You need to put delimiters (e.g. / or #) around your patterns:

$valid_match1 = '/"Times New Roman",Georgia,Serif/';
$valid_match2 = '/"Arial",Georgia,Serif/';
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.