Re: Re: splitting a string

From: Date: Tue, 05 Jan 2010 14:43:32 +0000
Subject: Re: Re: splitting a string
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-300814@lists.php.net to get a copy of this message
On Tue, 2010-01-05 at 08:45 -0600, Shawn McKenzie wrote: > Ingleby, Les wrote: > > Hi all, first time I have posted here so please be nice. > > > > I am using PEAR HTTP_Upload to handle multiple file uploads. What I need to do is to take > > the file name which is output using the getProp() function and then remove the file extension from > > the end of the file for example: > > > > Original name held in the getProp() array [name] "word_doccument.docx" > > > > I need to put this into a string such as > > > > $filename = $props['name']; > > > > I then need to separate the file name from the file extension. > > > > I have been reading the php manual do please don't bother referring me to that. > > > > Thanks in advance. > > > > LEGAL INFORMATION > > Information contained in this e-mail may be subject to public disclosure under the Freedom > > of Information Act 2000. Unless the information is legally exempt, the confidentiality of this > > e-mail and your reply cannot be guaranteed. > > Unless expressly stated otherwise, the information contained in this e-mail & any > > files transmitted with it are intended for the recipient only. If you are not the intended recipient > > you must not copy, distribute, or take any action or reliance upon it. If you have received this > > e-mail in error, you should notify the sender immediately and delete this email. Any unauthorised > > disclosure of the information contained in this e-mail is strictly prohibited. Any views or > > opinions presented are solely those of the author and do not necessarily represent those of Tyne > > Metropolitan College unless explicitly stated otherwise. > > This e-mail and attachments have been scanned for viruses prior to leaving Tyne > > Metropolitan College. Tyne Metropolitan College will not be liable for any losses as a result of any > > viruses being passed on. > > > > list($filename) = explode('.', $props['name']); > > Or if you may need the extension: > > list($filename, $extension) = explode('.', $props['name']); > > -- > Thanks! > -Shawn > http://www.spidean.com > I just though. How would all these methods fare when given a file like archive.tar.gz, where the .tar.gz is the full extension, not just the .gz? Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#300814) next »