Topic awaiting preservation: [php] How do you use a variable in a preg_match(/$var/) ? (img gallery) |
|
---|---|
Author | Thread |
Nervous Wreck (II) Inmate From: |
posted 11-08-2004 22:49
I think the problem is This line code: if(preg_match("/^$img_path_extless\.(png|jpg|gif)$/i", "$img_path", $matches)) I believe it's not using the content of the variable. I thought "\$var" or "\${var}" was supposed to work but it doesn't seem to. Or, maybe I have a logic error. code: images/ The problem is the thumbnails are always gifs "images/oil/image2.gif" but the full size image is not always a gif. ex: "images/oil/image2.jpg" code: <?php Line 69 is the preg_match I have at the beginning of this post, the $img_path_extless one. The errors I get code: Warning: Unknown modifier 'p' in /home/jake/public_html/school/art.php on line 69 (many times) Thanks for any help, |
Maniac (V) Mad Scientist From: :morF |
posted 11-09-2004 01:32
Concatonation should work, so instead of the code: if(preg_match("/^$img_path_extless\.(png|jpg|gif)$/i", "$img_path", $matches))
code: if(preg_match("/^".$img_path_extless."\.(png|jpg|gif)$/i", $img_path, $matches)) |
Nervous Wreck (II) Inmate From: mn |
posted 11-09-2004 04:44
I still get the same error: Warning: Unknown modifier 'p' in /home/jake/public_html/school/art.php on line 69 |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 11-09-2004 09:31
that's because there's a '/' in your $img_path_extless. Which you use as a regexps delimiter - wich of course will not work. |
Nervous Wreck (II) Inmate From: mn |
posted 11-10-2004 00:06
Tyberius Prime said:That fixes my regex, where did you find that information? (That ! can be used inplace of / in a regex) |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 11-10-2004 00:11
well the php->prce (perl style regexps overview) page states: quote:
|