note 46388 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:16:47 +0000
Subject: note 46388 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127583@lists.php.net to get a copy of this message
Note Submitter: j dot gizmo at aon dot at ---- in reply to rchoudhury --} pinkgreetings {-- com.... the code pasted below (with the switch statement) CANNOT work. the construct works like this <?php switch ($key) { case <expr>: //this will be executed if $key==<expr>, where <expr> can be a literal, function call etc. echo "1"; break; } //the following will work switch (true) { case preg_match("/pattern/",$key): //if $key matches pattern, preg_match will return true, and this case will be executed (true==true) blablablabla(); break; } ?> however, it makes no sense to compare $key to the return value of preg_match(), and calling preg_match without a second parameter is utterly senseless as well (PHP can't smell what you want to compare pattern to) the syntax error in your regular expression is the double slash in the beginning. (RTFM)

« previous php.notes (#127583) next »