Re: substr?
| From: | Jason Pruim | Date: | Fri, 20 Jun 2008 11:44:47 +0000 |
| Subject: | Re: substr? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275680@lists.php.net to get a copy of this message | ||
One of theses days I will ;)
But when you know a tool that will work and it's a simple little form that's only going to be used by a few people occasionally until this business takes off and I need to upgrade stuff... explode() works just fine :P
On Jun 19, 2008, at 6:18 PM, Philip Thompson wrote:
RTFM: http://www.php.net/strrpos Hehe =D "Find position of last occurrence of a char in a string" This avoids the extension containing multiple '.'s. ~Phil On Jun 19, 2008, at 1:02 PM, Jason Pruim wrote:-- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.comKnow what I found that works most reliably though? $filenameExploded = explode(".", $filename); that way, if I have a file like this: filename.todaysdate.todaystime.extension I don't end up with the extension being: .todaysdate.todaystime.extension :) Unless I was using the substr() command wrong. On Jun 19, 2008, at 1:53 PM, Philip Thompson wrote:"Personally, most of my web applications do not have to factor 13.7 billion years of space drift in to the calculations, so PHP's rand function has been great for me..." ~S. Johnson --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpDoes that get a different result than mine? ~Phil On Jun 19, 2008, at 10:44 AM, Daniel Brown wrote:-- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.comTry this: <?php $filename = 'this_example.php.file.backup.phps'; echo substr($filename,(strrpos($filename,'.') + 1),strlen($filename))."\n"; ?>--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php