On Tue, Jan 5, 2010 at 13:39, Ingleby, Les <les.in...@tynemet.ac.uk> 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.

There are a couple of ways you could do this. The most straightforward
way would be to use the pathinfo() function.

$file = 'word_document.docx';
$extension = pathinfo($file, PATHINFO_EXTENSION);
$name = pathinfo($file, PATHINFO_FILENAME);

See http://php.net/pathinfo for more information about that function.

You could also explode() it and do something with that, or you could
or use some of the other many string manipulation functions. I think
pathinfo() is easiest.

Daniel Egeberg

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

Reply via email to