splitting a string
am 05.01.2010 13:39:38 von les.ingey
--_000_4B67909E905B234BA0EB9F6DA7198DA84C0D9359C4xchange07nt yn_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
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 a=
nd 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 =3D $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 t=
hat.
Thanks in advance.
LEGAL INFORMATION=0D
Information contained in this e-mail may be subject to public disclosure un=
der the Freedom of Information Act 2000. Unless the information is legally =
exempt, the confidentiality of this e-mail and your reply cannot be guarant=
eed. =0D
Unless expressly stated otherwise, the information contained in this e-mail=
& any files transmitted with it are intended for the recipient only. If yo=
u 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 unauthoris=
ed disclosure of the information contained in this e-mail is strictly prohi=
bited. Any views or opinions presented are solely those of the author and =
do not necessarily represent those of Tyne Metropolitan College unless expl=
icitly stated otherwise.=0D
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.
--_000_4B67909E905B234BA0EB9F6DA7198DA84C0D9359C4xchange07nt yn_--
Re: splitting a string
am 05.01.2010 14:13:29 von Ashley Sheridan
--=-nn0DsiOStmEcEiBYjW/F
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Tue, 2010-01-05 at 12:39 +0000, 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.
PHPBB uses the substr() function along with the strrpos() function to
grab the extension from a file. You could do something like this:
(untested - I always forget the order of the params!)
$name = substr($filename, 0, strrpos($filename, '.'));
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-nn0DsiOStmEcEiBYjW/F--
Re: splitting a string
am 05.01.2010 14:15:39 von Daniel Egeberg
On Tue, Jan 5, 2010 at 13:39, 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.
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
Re: splitting a string
am 05.01.2010 14:25:11 von Ashley Sheridan
--=-ilesDckp85Ufn76P3l9F
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Tue, 2010-01-05 at 14:26 +0100, Daniel Egeberg wrote:
> On Tue, Jan 5, 2010 at 14:13, Ashley Sheridan wrote:
> > (untested - I always forget the order of the params!)
>
> As a general rule, string functions are always haystack-needle and
> array functions are always needle-haystack. I can't think of any
> exceptions to that rule.
>
> --
> Daniel Egeberg
>
Thanks! I'll try and remember that. It'll save me many trips to the
manual pages as well!
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-ilesDckp85Ufn76P3l9F--
Re: splitting a string
am 05.01.2010 14:26:00 von Daniel Egeberg
On Tue, Jan 5, 2010 at 14:13, Ashley Sheridan wrote:
> (untested - I always forget the order of the params!)
As a general rule, string functions are always haystack-needle and
array functions are always needle-haystack. I can't think of any
exceptions to that rule.
--
Daniel Egeberg
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 15:43:32 von Ashley Sheridan
--=-48mpdr3KfAMsrowFVF7G
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
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
--=-48mpdr3KfAMsrowFVF7G--
Re: splitting a string
am 05.01.2010 15:45:32 von Shawn McKenzie
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re: splitting a string
am 05.01.2010 16:03:07 von les.ingey
Hi everyone, thanks so much for your help. The pathinfo($filename, PATHINFO=
_FILENAME); works a treat for me, since I am dealing and will only be deali=
ng with a word doc then this is awesome.
Still new to PHP but self taught and scripting is coming on hence I don't k=
now many functions just yet.
-----Original Message-----
From: Shawn McKenzie [mailto:nospam@mckenzies.net]=20
Sent: 05 January 2010 15:09
To: ash@ashleysheridan.co.uk
Cc: Ingleby, Les; php-general@lists.php.net
Subject: Re: [PHP] Re: splitting a string
Ashley Sheridan wrote:
> On Tue, 2010-01-05 at 08:45 -0600, Shawn McKenzie wrote:
>=20
>> 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 nee=
d to do is to take the file name which is output using the getProp() functi=
on 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 =3D $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 disclosur=
e under the Freedom of Information Act 2000. Unless the information is lega=
lly exempt, the confidentiality of this e-mail and your reply cannot be gua=
ranteed.=20
>>> Unless expressly stated otherwise, the information contained in this e-=
mail & any files transmitted with it are intended for the recipient only. I=
f 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 unauth=
orised disclosure of the information contained in this e-mail is strictly p=
rohibited. 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 leav=
ing Tyne Metropolitan College. Tyne Metropolitan College will not be liable=
for any losses as a result of any viruses being passed on.
>>>
>> list($filename) =3D explode('.', $props['name']);
>>
>> Or if you may need the extension:
>>
>> list($filename, $extension) =3D explode('.', $props['name']);
>>
>> --=20
>> Thanks!
>> -Shawn
>> http://www.spidean.com
>>
>=20
>=20
> 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?
>=20
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>=20
>=20
Well I thought about that when I posted. If all you're concerned about
is the filename then my first example works great, for the second to get
the full extension you would set a limit to only return the first part
before the . and then all the rest (assuming that the rest is the
extension):
list($filename, $extension) =3D explode('.', 'archive.tar.gz', 2);
Of course this doesn't work for something like 'My.Word.Document.docx'
or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
being variable length and possibly composed of multiple periods.
--=20
Thanks!
-Shawn
http://www.spidean.com
LEGAL INFORMATION=0D
Information contained in this e-mail may be subject to public disclosure un=
der the Freedom of Information Act 2000. Unless the information is legally =
exempt, the confidentiality of this e-mail and your reply cannot be guarant=
eed. =0D
Unless expressly stated otherwise, the information contained in this e-mail=
& any files transmitted with it are intended for the recipient only. If yo=
u 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 unauthoris=
ed disclosure of the information contained in this e-mail is strictly prohi=
bited. Any views or opinions presented are solely those of the author and =
do not necessarily represent those of Tyne Metropolitan College unless expl=
icitly stated otherwise.=0D
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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 16:07:30 von Richard Quadling
2010/1/5 Ashley Sheridan :
> 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 ne=
ed to do is to take the file name which is output using the getProp() funct=
ion 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 =3D $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 disclosu=
re under the Freedom of Information Act 2000. Unless the information is leg=
ally exempt, the confidentiality of this e-mail and your reply cannot be gu=
aranteed.
>> > 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 tak=
e 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 unaut=
horised disclosure of the information contained in this e-mail is strictly =
prohibited. Â Any views or opinions presented are solely those of the a=
uthor and do not necessarily represent those of Tyne Metropolitan College u=
nless explicitly stated otherwise.
>> > This e-mail and attachments have been scanned for viruses prior to lea=
ving Tyne Metropolitan College. Tyne Metropolitan College will not be liabl=
e for any losses as a result of any viruses being passed on.
>> >
>>
>> list($filename) =3D explode('.', $props['name']);
>>
>> Or if you may need the extension:
>>
>> list($filename, $extension) =3D 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
>
>
>
$file =3D 'archve.tar.gz';
$pathinfo_extension =3D pathinfo($file, PATHINFO_EXTENSION);
$pathinfo_name =3D pathinfo($file, PATHINFO_FILENAME);
$substr_right_name =3D substr($file, 0, strrpos($file, '.'));
$substr_right_extension =3D substr($file, strrpos($file, '.'));
$substr_left_name =3D substr($file, 0, strpos($file, '.'));
$substr_left_extension =3D substr($file, strpos($file, '.'));
list($list_name, $list_extension) =3D explode('.', $file);
echo "
Original : $file
Pathinfo : $pathinfo_name / $pathinfo_extension
Substr (right) : $substr_right_name / $substr_right_extension
Substr (left) : $substr_left_name / $substr_left_extension
List : $list_name / $list_extension
";
?>
outputs ...
Original : archve.tar.gz
Pathinfo : archve.tar / gz
Substr (right) : archve.tar / .gz
Substr (left) : archve / .tar.gz
List : archve / tar
The only option that seems to be working here (and one that wasn't
previously suggested) is to use
$substr_left_name =3D substr($file, 0, strpos($file, '.'));
$substr_left_extension =3D substr($file, strpos($file, '.'));
--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 16:09:04 von Shawn McKenzie
Ashley Sheridan wrote:
> 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
>
>
Well I thought about that when I posted. If all you're concerned about
is the filename then my first example works great, for the second to get
the full extension you would set a limit to only return the first part
before the . and then all the rest (assuming that the rest is the
extension):
list($filename, $extension) = explode('.', 'archive.tar.gz', 2);
Of course this doesn't work for something like 'My.Word.Document.docx'
or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
being variable length and possibly composed of multiple periods.
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 16:17:59 von Richard Quadling
2010/1/5 Ingleby, Les :
> Hi everyone, thanks so much for your help. The pathinfo($filename, PATHIN=
FO_FILENAME); works a treat for me, since I am dealing and will only be dea=
ling with a word doc then this is awesome.
>
> Still new to PHP but self taught and scripting is coming on hence I don't=
know many functions just yet.
>
> -----Original Message-----
> From: Shawn McKenzie [mailto:nospam@mckenzies.net]
> Sent: 05 January 2010 15:09
> To: ash@ashleysheridan.co.uk
> Cc: Ingleby, Les; php-general@lists.php.net
> Subject: Re: [PHP] Re: splitting a string
>
> Ashley Sheridan wrote:
>> 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 ne=
ed to do is to take the file name which is output using the getProp() funct=
ion 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 =3D $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 disclosu=
re under the Freedom of Information Act 2000. Unless the information is leg=
ally exempt, the confidentiality of this e-mail and your reply cannot be gu=
aranteed.
>>>> 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 tak=
e 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 unaut=
horised disclosure of the information contained in this e-mail is strictly =
prohibited. Â Any views or opinions presented are solely those of the a=
uthor and do not necessarily represent those of Tyne Metropolitan College u=
nless explicitly stated otherwise.
>>>> This e-mail and attachments have been scanned for viruses prior to lea=
ving Tyne Metropolitan College. Tyne Metropolitan College will not be liabl=
e for any losses as a result of any viruses being passed on.
>>>>
>>> list($filename) =3D explode('.', $props['name']);
>>>
>>> Or if you may need the extension:
>>>
>>> list($filename, $extension) =3D 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
>>
>>
>
> Well I thought about that when I posted. Â If all you're concerned ab=
out
> is the filename then my first example works great, for the second to get
> the full extension you would set a limit to only return the first part
> before the . and then all the rest (assuming that the rest is the
> extension):
>
> list($filename, $extension) =3D explode('.', 'archive.tar.gz', 2);
>
> Of course this doesn't work for something like 'My.Word.Document.docx'
> or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
> being variable length and possibly composed of multiple periods.
>
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> 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 legall=
y exempt, the confidentiality of this e-mail and your reply cannot be guara=
nteed.
> Unless expressly stated otherwise, the information contained in this e-ma=
il & 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 a=
ny action or reliance upon it. If you have received this e-mail in error, y=
ou should notify the sender immediately and delete this email. Any unauthor=
ised disclosure of the information contained in this e-mail is strictly pro=
hibited. Â Any views or opinions presented are solely those of the auth=
or and do not necessarily represent those of Tyne Metropolitan College unle=
ss explicitly stated otherwise.
> This e-mail and attachments have been scanned for viruses prior to leavin=
g Tyne Metropolitan College. Tyne Metropolitan College will not be liable f=
or any losses as a result of any viruses being passed on.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Make sure you check out the documentation at http://www.php.net/manual/en.
You can use http://www.php.net/function_name_here as a short cut -
e.g. http://www.php.net/substr
Pick one of the functions we've mentioned and follow the "See also"
for other related functions.
Regards,
Richard.
--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 16:18:16 von Daniel Egeberg
On Tue, Jan 5, 2010 at 16:09, Shawn McKenzie wrote:
> Of course this doesn't work for something like 'My.Word.Document.docx'
> or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
> being variable length and possibly composed of multiple periods.
I suppose a solution to that could be having a list of known file
extensions and use that while falling back to one of the methods given
in this thread if there is no match in the list. Of course you would
then have to check .tar.gz before .gz if you're just iterating through
a list. You might also just choose the longest match (in terms of
number of periods).
--
Daniel Egeberg
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 16:20:19 von Ashley Sheridan
--=-BWQy35dhNrYXeqQr3SsD
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Tue, 2010-01-05 at 16:18 +0100, Daniel Egeberg wrote:
> On Tue, Jan 5, 2010 at 16:09, Shawn McKenzie wrote:
> > Of course this doesn't work for something like 'My.Word.Document.docx'
> > or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
> > being variable length and possibly composed of multiple periods.
>
> I suppose a solution to that could be having a list of known file
> extensions and use that while falling back to one of the methods given
> in this thread if there is no match in the list. Of course you would
> then have to check .tar.gz before .gz if you're just iterating through
> a list. You might also just choose the longest match (in terms of
> number of periods).
>
That was my thought on how operating systems did it. If it maybe can't
find a matching pattern, then it can fall back to matching anything
after the last period.
It always puzzles me, because some.archive.tar.gz is a valid file, but
the extension is .tar.gz and the filename is some.archive. I guess it
must compare the full filename to a list of knowns, and then try it's
best after that.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-BWQy35dhNrYXeqQr3SsD--
Re: Re: splitting a string
am 05.01.2010 18:18:29 von Andrew Ballard
On Tue, Jan 5, 2010 at 10:20 AM, Ashley Sheridan
wrote:
> On Tue, 2010-01-05 at 16:18 +0100, Daniel Egeberg wrote:
>
>> On Tue, Jan 5, 2010 at 16:09, Shawn McKenzie wrote:
>> > Of course this doesn't work for something like 'My.Word.Document.docx'
>> > or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
>> > being variable length and possibly composed of multiple periods.
>>
>> I suppose a solution to that could be having a list of known file
>> extensions and use that while falling back to one of the methods given
>> in this thread if there is no match in the list. Of course you would
>> then have to check .tar.gz before .gz if you're just iterating through
>> a list. You might also just choose the longest match (in terms of
>> number of periods).
>>
>
>
> That was my thought on how operating systems did it. If it maybe can't
> find a matching pattern, then it can fall back to matching anything
> after the last period.
>
> It always puzzles me, because some.archive.tar.gz is a valid file, but
> the extension is .tar.gz and the filename is some.archive. I guess it
> must compare the full filename to a list of knowns, and then try it's
> best after that.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
While relying on a file's extension to determine the type of its
contents is dangerous, isn't archive.tar.gz just a gzip'd file that
happens to contain a tarball named archive.tar? In that case, wouldn't
the correct extension just be .gz?
Andrew
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: splitting a string
am 05.01.2010 18:40:33 von Shawn McKenzie
Andrew Ballard wrote:
> On Tue, Jan 5, 2010 at 10:20 AM, Ashley Sheridan
> wrote:
>> On Tue, 2010-01-05 at 16:18 +0100, Daniel Egeberg wrote:
>>
>>> On Tue, Jan 5, 2010 at 16:09, Shawn McKenzie wrote:
>>>> Of course this doesn't work for something like 'My.Word.Document.docx'
>>>> or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
>>>> being variable length and possibly composed of multiple periods.
>>> I suppose a solution to that could be having a list of known file
>>> extensions and use that while falling back to one of the methods given
>>> in this thread if there is no match in the list. Of course you would
>>> then have to check .tar.gz before .gz if you're just iterating through
>>> a list. You might also just choose the longest match (in terms of
>>> number of periods).
>>>
>>
>> That was my thought on how operating systems did it. If it maybe can't
>> find a matching pattern, then it can fall back to matching anything
>> after the last period.
>>
>> It always puzzles me, because some.archive.tar.gz is a valid file, but
>> the extension is .tar.gz and the filename is some.archive. I guess it
>> must compare the full filename to a list of knowns, and then try it's
>> best after that.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>
> While relying on a file's extension to determine the type of its
> contents is dangerous, isn't archive.tar.gz just a gzip'd file that
> happens to contain a tarball named archive.tar? In that case, wouldn't
> the correct extension just be .gz?
>
> Andrew
Yes, or .tgz sometimes.
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re: splitting a string
am 05.01.2010 18:51:34 von Bob McConnell
From: Shawn McKenzie [mailto:nospam@mckenzies.net]=20
> Andrew Ballard wrote:
>> On Tue, Jan 5, 2010 at 10:20 AM, Ashley Sheridan
>> wrote:
>>> On Tue, 2010-01-05 at 16:18 +0100, Daniel Egeberg wrote:
>>>
>>>> On Tue, Jan 5, 2010 at 16:09, Shawn McKenzie
wrote:
>>>>> Of course this doesn't work for something like
'My.Word.Document.docx'
>>>>> or 'archive_v2.0.1.tar.gz', but I don't know what will with
extensions
>>>>> being variable length and possibly composed of multiple periods.
>>>> I suppose a solution to that could be having a list of known file
>>>> extensions and use that while falling back to one of the methods
given
>>>> in this thread if there is no match in the list. Of course you
would
>>>> then have to check .tar.gz before .gz if you're just iterating
through
>>>> a list. You might also just choose the longest match (in terms of
>>>> number of periods).
>>>>
>>>
>>> That was my thought on how operating systems did it. If it maybe
can't
>>> find a matching pattern, then it can fall back to matching anything
>>> after the last period.
>>>
>>> It always puzzles me, because some.archive.tar.gz is a valid file,
but
>>> the extension is .tar.gz and the filename is some.archive. I guess
it
>>> must compare the full filename to a list of knowns, and then try
it's
>>> best after that.
>>=20
>> While relying on a file's extension to determine the type of its
>> contents is dangerous, isn't archive.tar.gz just a gzip'd file that
>> happens to contain a tarball named archive.tar? In that case,
wouldn't
>> the correct extension just be .gz?
>>=20
>> Andrew
>=20
> Yes, or .tgz sometimes.
>=20
Most of the time .tgz indicates more than just a gzipped tar file. It
has always been used by Slackware to indicate specific control files
have been added for their package manager.
But that has always been the danger of using the extension instead of
the magic number to identify the file type. Too many extensions have
been overloaded.
Bob McConnell
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php