RE: [SMARTY] selecting 4 characters starting from right of string
| From: | Hoffman, Geoffrey | Date: | Thu, 17 Feb 2005 16:14:22 +0000 |
| Subject: | RE: [SMARTY] selecting 4 characters starting from right of string | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-12250@lists.php.net to get a copy of this message | ||
Jean-Marc,
True true. Your point about performance is valid (although using the $
matches only the end in a preg_match so it wouldn't match .jpg.exe but
anyway substr is faster you're right) - but I would still tend to make a
plugin over putting php code in a template -
Cheers
* * *
Geoff
-----Original Message-----
From: Jean-Marc Fontaine
Sent: Thursday, February 17, 2005 9:13 AM
Subject: Re: [SMARTY] selecting 4 characters starting from right of string
Hello Geoffrey,
You should not use a regular expression for this purpose for performance
sake. A substr() is powerful enough.
BTW, your regular expression pattern will also match this filename
"dummy.jpg.exe". It's quite dangereous.
Regards.
Jean-Marc