PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Graphisme & Infographie > macromedia.dreamweaver > PHP-regex -simple question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHP-regex -simple question

Réponse
 
LinkBack Outils de la discussion
Vieux 01/06/2008, 19h01   #1
(_seb_)
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHP-regex -simple question

Hi all
If I am using a regex like this:

<?php
if(preg_match('/(jpe?g?|png|gif)$/i',$extension)){
do something...
}
?>

It works.

But if I do:

<?php
$images = 'jpe?g?|png|gif';
if(preg_match('/('.$images.')$/i',$extension)){
do something...
}
?>

(I simply replaced the content of the regex between parenthesis with the variable $images.)
It does not work, it seems that whatever the extension is, it always matches.

That's probably very stupid, but it's bugging me
What am I missing?

--
seb (@webtrans1.com)

high-end web design: http://webtrans1.com

Sign-up for a free beta test of SiteLander, an ingenious website-builder:
http://webtrans1.com/sitelander/

music: http://myspace.com/popmodelberlin
  Réponse avec citation
Vieux 01/06/2008, 19h43   #2
(_seb_)
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP-regex -simple question

OK so I also tried this:

$images = '/(jpe?g?|png|gif)$/i';

if(preg_match($images, $extension)){
do_something
}

it does not work either. Now there is never a match.

I guess it must be a problem with the modifiers at the end of the variable used as a pattern?

How should I do this????

--
seb (@webtrans1.com)

high-end web design: http://webtrans1.com

Sign-up for a free beta test of SiteLander, an ingenious website-builder:
http://webtrans1.com/sitelander/

music: http://myspace.com/popmodelberlin
  Réponse avec citation
Vieux 01/06/2008, 20h20   #3
(_seb_)
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP-regex -simple question

(_seb_) wrote:
> OK so I also tried this:
>
> $images = '/(jpe?g?|png|gif)$/i';
>
> if(preg_match($images, $extension)){
> do_something
> }
>
> it does not work either. Now there is never a match.
>
> I guess it must be a problem with the modifiers at the end of the
> variable used as a pattern?
>
> How should I do this????
>


OOps!

it was another stupid error that had nothing to do with the regex... sorry.

--
seb (@webtrans1.com)

high-end web design: http://webtrans1.com

Sign-up for a free beta test of SiteLander, an ingenious website-builder:
http://webtrans1.com/sitelander/

music: http://myspace.com/popmodelberlin
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h30.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11636 seconds with 11 queries