Re: substr?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

Know 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:

Does that get a different result than mine?

~Phil


On Jun 19, 2008, at 10:44 AM, Daniel Brown wrote:

Try 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



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx





"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.php



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux