RobinTibbs Posted January 19, 2007 Share Posted January 19, 2007 pretty simple q which i can't seem to find an answer to, can i include a variable in a regular expression as such:[code]$array = ( ....... );foreach($array as $value) {preg_match('($value)', <string>, $matches);}[/code] Link to comment https://forums.phpfreaks.com/topic/34890-variables-in-regular-expressions/ Share on other sites More sharing options...
effigy Posted January 19, 2007 Share Posted January 19, 2007 Yes. The same PHP syntax rules apply: variables are not interpolated in single quotes. Use double quotes or concatenation. Link to comment https://forums.phpfreaks.com/topic/34890-variables-in-regular-expressions/#findComment-164463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.