Jump to content

Preg Match - if


jaymc

Recommended Posts

[quote]Here is my code

<?php
$string = "hi &?/\='\",%+ hi";
$patterns[0] = "/&/";
$patterns[1] = "/\?/";
$patterns[3] = "/\//";
$patterns[4] = "/\\\/";
$patterns[5] = "/=/";
$patterns[6] = "/'/";
$patterns[7] = "/\"/";
$patterns[8] = "/,/";
$patterns[9] = "/%/";
$patterns[10] = "/\+/";

if (preg_match($patterns, $string)) {echo "YES";} else {echo "NO";}
?>[/quote]

Just wondering why I get an error when running that

[i]Warning: preg_match() expects parameter 1 to be string, array given in /home/cff/public_html/testy.php on line 28
NO [/i]
Link to comment
https://forums.phpfreaks.com/topic/28378-preg-match-if/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.