Re: [PHP] Whats the best way?

2002-05-20 Thread Analysis Solutions

Gerard:

On Sat, May 18, 2002 at 12:38:37PM -0400, Gerard Samuel wrote:

 HTTP_ACCEPT_LANGUAGE is 'en-us, en;q=0.75, nl;q=0.50, fr;q=0.25'
 
 $foo = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
 foreach ($foo as $bar) {
$string = 
 preg_replace(/([a-z]{2})|(-[a-z]{2})|(;q=[0-9]\.[0-9]{2})/i, $1, 
 trim($bar));
$array[] = $string;
 }

The replacements supposed to be \\1 rather than $1.  But, $1 might work
anyway.  Also, you can just assign the fuction to $array[], rather than
assigning it to $string and then $string to $array[].  But, even better,
use preg_match_all:
   http://www.php.net/manual/en/function.preg-match-all.php

That'll eliminate the need to split() first.  Just put the stuff you 
want to keep, ie the two lettered language codes, in subpatterns () 
and keep the rest of the stuff out of sub patterns.

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




[PHP] Whats the best way?

2002-05-18 Thread Gerard Samuel

Well this is the first time actually creating a regex.
It works, but was wondering if the regex was created properly.

HTTP_ACCEPT_LANGUAGE is 'en-us, en;q=0.75, nl;q=0.50, fr;q=0.25'

/* Explode the browser report to get each language */
$foo = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );

/* Perform a regex to get the first 2 letters for each language reported */
foreach ($foo as $bar) {
$string = 
preg_replace(/([a-z]{2})|(-[a-z]{2})|(;q=[0-9]\.[0-9]{2})/i, $1, 
trim($bar));
$array[] = $string;
}

Thanks


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




[PHP] Whats the best way.

2002-01-24 Thread Philip J. Newman

Whats the best way that I can let users upload single .jpeg and gif files, renaming 
then with a time stamp?

Philip J. Newman
Philip's Domain - Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]
Phone: +64 25 6144012



Re: [PHP] Whats the best way.

2002-01-24 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* and then Philip J. Newman blurted
 Whats the best way that I can let users upload single .jpeg and gif files, renaming 
then with a time stamp?

RTFM
There's a *big* section on file uploads :=)
- -- 

Nick Wilson

Tel:+45 3325 0688
Fax:+45 3325 0677
Web:www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8T8uWHpvrrTa6L5oRAmHLAJ9dFeAHlDSQ/GgNL1RjimxBroUP+ACgs1la
b5aMlxJGT02VtHr7c3XmEas=
=v0N1
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats the best way.

2002-01-24 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* and then Philip J. Newman blurted
 Nice, how rude, but nice.

Didn't really mean to be rude hence the concessional smiley at the end. 

Regards
- -- 

Nick Wilson

Tel:+45 3325 0688
Fax:+45 3325 0677
Web:www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8T86UHpvrrTa6L5oRAl+IAJ4iZLSWg15yBgCZA2Ohl2bj0iLlPgCgkC4y
zzo7R1x4GgRGrg2gKxP+/ZM=
=2+xd
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats the best way.

2002-01-24 Thread Stefan Rusterholz

Read this through: http://www.php.net/manual/en/features.file-upload.php
Consider then: http://www.php.net/manual/en/function.is-uploaded-file.php
After that read:
http://www.php.net/manual/en/function.move-uploaded-file.php

and then do it like that:
-upload form
-check if user has uploaded a file (he could have sent an empty form)
-check what extension is needed (.jpg, .gif or whatever)
-move_uploaded_file($userfile, Your/Directory/.time().$extension)

hope this helps
stefan rusterholz

- Original Message -
From: Philip J. Newman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, January 24, 2002 9:47 AM
Subject: [PHP] Whats the best way.


Whats the best way that I can let users upload single .jpeg and gif files,
renaming then with a time stamp?

Philip J. Newman
Philip's Domain - Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]
Phone: +64 25 6144012



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]