Re: shorthand with ~

From: Date: Mon, 08 Mar 2004 23:18:50 +0000
Subject: Re: shorthand with ~
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-23775@lists.php.net to get a copy of this message
Hi John, As far as I can see, you didn't understand the power of regular expressions. Plus in your case, you don't need them at all. Use something like in_array() to do what you need, it will be shorter and faster. For further questions, please ask at php-general@lists.php.net, webmaster@php.net is not the good place. Mehdi Achour John N. wrote:
To whom it may concern: I was working on a program for a client tonight, and realized that a lot of my function uses are usually pretty long if they have multiple conditions in which the function is used repeatedly. You might consider adding a shorthand way of adding multiple conditions (for this example, in an if statement): An example of this: if( ! ereg( "PHPSESSID","$KEY" ) and ! ereg( "poc_theme","$KEY" ) and ! ereg( "mode","$KEY" ) and ! ereg( "question","$KEY" ) ) { Could be shortened to: if( ! ereg( "PHPSESSID","$KEY"~"poc_theme","$KEY"~"mode","$KEY"~"question","$KEY") ) { This would save a small amount of space and a little bit of bandwidth, but anything helps when you've got a high-volume website. What I did was this: In the function "ereg", I entered one condition, then allowed for the entering of another one by putting a tilde between each one. I Thought about other symbols that could be used, but I think ~ is the only one that's not in use at the moment. Thanks for the taking the time to read this. <>< john nicely


« previous php.mirrors (#23775) next »