For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > February 2005 > RE: [SMARTY] selecting 4 characters starting from right of string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [SMARTY] selecting 4 characters starting from right of string
Geoffrey Hoffman

2005-02-17, 4:08 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com