RE: [PHP-DEV] function suggestion

2001-05-21 Thread Sean R. Bright

This is now implemented in the latest CVS.  Grab it from there or try a
snaps.php.net sometime tomorrow.

Sean

 -Original Message-
 From: Alex Black [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 20, 2001 8:39 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DEV] function suggestion


 I would like to suggest a function:

 get_defined_constants();
 which returns an array of constant name/value pairs.

 _alex


 --
 PHP Development 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]




-- 
PHP Development 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]




[PHP-DEV] function suggestion

2001-05-20 Thread Alex Black

I would like to suggest a function:

get_defined_constants();
which returns an array of constant name/value pairs.

_alex


-- 
PHP Development 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-DEV] Function suggestion

2001-04-11 Thread Wico de Leeuw

At 12:43 10-4-2001 -0700, Rasmus Lerdorf wrote:
Hiya

I have been using this (selfmade) function for ages:

function String_Replace_Foreign_Chars ($data) {
 return(strtr($data, 
"",
 "AAaaCcDNnO0oo0YyyB"));
}

Greetz,

Wico

Using str_replace() would speed this function up by an order of magnitude.

On Tue, 10 Apr 2001, Lindsey Simon wrote:

  I'm not positive I'm mailing to the right list, but I have a function 
 that might be useful
  to others. I often use php to retrieve a name from a database and then 
 let a user upload a
  file and I name that file by as $user.mp3(in this case). I need to 
 convert all of the
  international characters to a standard character for this since 
 different OS's send
  requests for filenames with non-standard standards...
 
  so here goes:
 
  function intl2plain ($thing) {
$thing = preg_replace("/xE0/", "a", $thing);
$thing = preg_replace("/xE8/", "e", $thing);
$thing = preg_replace("/xEC/", "i", $thing);
$thing = preg_replace("/xF2/", "o", $thing);
$thing = preg_replace("/xF9/", "u", $thing);
 
$thing = preg_replace("/\xC0/", "A", $thing);
$thing = preg_replace("/\xC8/", "E", $thing);
$thing = preg_replace("/\xCC/", "I", $thing);
$thing = preg_replace("/\xD2/", "O", $thing);
$thing = preg_replace("/\xD9/", "U", $thing);
 
$thing = preg_replace("/\xE1/", "a", $thing);
$thing = preg_replace("/\xE9/", "e", $thing);
$thing = preg_replace("/\xED/", "i", $thing);
$thing = preg_replace("/\xF3/", "o", $thing);
$thing = preg_replace("/\xFA/", "u", $thing);
$thing = preg_replace("/\xFD/", "y", $thing);
 
$thing = preg_replace("/\xC1/", "A", $thing);
$thing = preg_replace("/\xC9/", "E", $thing);
$thing = preg_replace("/\xCD/", "I", $thing);
$thing = preg_replace("/\xD3/", "O", $thing);
$thing = preg_replace("/\xDA/", "U", $thing);
$thing = preg_replace("/\xDD/", "Y", $thing);
 
$thing = preg_replace("/\xE2/", "a", $thing);
$thing = preg_replace("/\xEA/", "e", $thing);
$thing = preg_replace("/\xEE/", "i", $thing);
$thing = preg_replace("/\xF4/", "o", $thing);
$thing = preg_replace("/\xFB/", "u", $thing);
 
$thing = preg_replace("/\xC2/", "A", $thing);
$thing = preg_replace("/\xCA/", "E", $thing);
$thing = preg_replace("/\xCE/", "I", $thing);
$thing = preg_replace("/\xD4/", "O", $thing);
$thing = preg_replace("/\xDB/", "U", $thing);
 
$thing = preg_replace("/\xE3/", "a", $thing);
$thing = preg_replace("/\xF1/", "n", $thing);
$thing = preg_replace("/\xF5/", "o", $thing);
 
$thing = preg_replace("/\xC3/", "A", $thing);
$thing = preg_replace("/\xD1/", "N", $thing);
$thing = preg_replace("/\xD5/", "O", $thing);
 
$thing = preg_replace("/\xE4/", "a", $thing);
$thing = preg_replace("/\xEB/", "e", $thing);
$thing = preg_replace("/\xEF/", "i", $thing);
$thing = preg_replace("/\xF6/", "o", $thing);
$thing = preg_replace("/\xFC/", "u", $thing);
$thing = preg_replace("/\xFF/", "y", $thing);
 
$thing = preg_replace("/\xC4/", "A", $thing);
$thing = preg_replace("/\xCB/", "E", $thing);
$thing = preg_replace("/\xCF/", "I", $thing);
$thing = preg_replace("/\xD6/", "O", $thing);
$thing = preg_replace("/\xDC/", "U", $thing);
$thing = preg_replace("/\x9f/", "Y", $thing);
 
$thing = preg_replace("/\xE7/", "c", $thing);
$thing = preg_replace("/\xC7/", "C", $thing);
 
return $thing;
  }
 
  Maybe it's useful for others, it's along the lines of 
 htmlspecialchars(); etc...
 
  -lindsey
 
 
  --
  PHP Development 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]
 


--
PHP Development 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]


--
PHP Development 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-DEV] Function suggestion

2001-04-11 Thread Hartmut Holzgraefe

Rasmus Lerdorf wrote:
 Using str_replace() would speed this function up by an order of magnitude.

the second variant of strtr() as described in the manual would do even
better i guess

but anyway, php-dev is probably *not* the right place for this topic

Lindsey, pleas post to php-general next time, php-dev is about the
further
developement of php itself, not php application programming
whenever you see a piece of code here it will be most likely C, not PHP
source :)

-- 
Hartmut Holzgraefe  [EMAIL PROTECTED]  http://www.six.de  +49-711-99091-77

-- 
PHP Development 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]




[PHP-DEV] Function suggestion

2001-04-10 Thread Lindsey Simon

I'm not positive I'm mailing to the right list, but I have a function that might be 
useful
to others. I often use php to retrieve a name from a database and then let a user 
upload a
file and I name that file by as $user.mp3(in this case). I need to convert all of the
international characters to a standard character for this since different OS's send
requests for filenames with non-standard standards...

so here goes:

function intl2plain ($thing) {
  $thing = preg_replace("/xE0/", "a", $thing);
  $thing = preg_replace("/xE8/", "e", $thing);
  $thing = preg_replace("/xEC/", "i", $thing);
  $thing = preg_replace("/xF2/", "o", $thing);
  $thing = preg_replace("/xF9/", "u", $thing);
  
  $thing = preg_replace("/\xC0/", "A", $thing);
  $thing = preg_replace("/\xC8/", "E", $thing);
  $thing = preg_replace("/\xCC/", "I", $thing);
  $thing = preg_replace("/\xD2/", "O", $thing);
  $thing = preg_replace("/\xD9/", "U", $thing);
  
  $thing = preg_replace("/\xE1/", "a", $thing);
  $thing = preg_replace("/\xE9/", "e", $thing);
  $thing = preg_replace("/\xED/", "i", $thing);
  $thing = preg_replace("/\xF3/", "o", $thing);
  $thing = preg_replace("/\xFA/", "u", $thing);
  $thing = preg_replace("/\xFD/", "y", $thing);
  
  $thing = preg_replace("/\xC1/", "A", $thing);
  $thing = preg_replace("/\xC9/", "E", $thing);
  $thing = preg_replace("/\xCD/", "I", $thing);
  $thing = preg_replace("/\xD3/", "O", $thing);
  $thing = preg_replace("/\xDA/", "U", $thing);
  $thing = preg_replace("/\xDD/", "Y", $thing);
  
  $thing = preg_replace("/\xE2/", "a", $thing);
  $thing = preg_replace("/\xEA/", "e", $thing);
  $thing = preg_replace("/\xEE/", "i", $thing);
  $thing = preg_replace("/\xF4/", "o", $thing);
  $thing = preg_replace("/\xFB/", "u", $thing);
  
  $thing = preg_replace("/\xC2/", "A", $thing);
  $thing = preg_replace("/\xCA/", "E", $thing);
  $thing = preg_replace("/\xCE/", "I", $thing);
  $thing = preg_replace("/\xD4/", "O", $thing);
  $thing = preg_replace("/\xDB/", "U", $thing);
  
  $thing = preg_replace("/\xE3/", "a", $thing);
  $thing = preg_replace("/\xF1/", "n", $thing);
  $thing = preg_replace("/\xF5/", "o", $thing);
  
  $thing = preg_replace("/\xC3/", "A", $thing);
  $thing = preg_replace("/\xD1/", "N", $thing);
  $thing = preg_replace("/\xD5/", "O", $thing);
  
  $thing = preg_replace("/\xE4/", "a", $thing);
  $thing = preg_replace("/\xEB/", "e", $thing);
  $thing = preg_replace("/\xEF/", "i", $thing);
  $thing = preg_replace("/\xF6/", "o", $thing);
  $thing = preg_replace("/\xFC/", "u", $thing);
  $thing = preg_replace("/\xFF/", "y", $thing);
   
  $thing = preg_replace("/\xC4/", "A", $thing);
  $thing = preg_replace("/\xCB/", "E", $thing);
  $thing = preg_replace("/\xCF/", "I", $thing);
  $thing = preg_replace("/\xD6/", "O", $thing);
  $thing = preg_replace("/\xDC/", "U", $thing);
  $thing = preg_replace("/\x9f/", "Y", $thing);
  
  $thing = preg_replace("/\xE7/", "c", $thing);
  $thing = preg_replace("/\xC7/", "C", $thing);

  return $thing;
}

Maybe it's useful for others, it's along the lines of htmlspecialchars(); etc...

-lindsey


-- 
PHP Development 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-DEV] Function suggestion

2001-04-10 Thread Rasmus Lerdorf

Using str_replace() would speed this function up by an order of magnitude.

On Tue, 10 Apr 2001, Lindsey Simon wrote:

 I'm not positive I'm mailing to the right list, but I have a function that might be 
useful
 to others. I often use php to retrieve a name from a database and then let a user 
upload a
 file and I name that file by as $user.mp3(in this case). I need to convert all of the
 international characters to a standard character for this since different OS's send
 requests for filenames with non-standard standards...

 so here goes:

 function intl2plain ($thing) {
   $thing = preg_replace("/xE0/", "a", $thing);
   $thing = preg_replace("/xE8/", "e", $thing);
   $thing = preg_replace("/xEC/", "i", $thing);
   $thing = preg_replace("/xF2/", "o", $thing);
   $thing = preg_replace("/xF9/", "u", $thing);

   $thing = preg_replace("/\xC0/", "A", $thing);
   $thing = preg_replace("/\xC8/", "E", $thing);
   $thing = preg_replace("/\xCC/", "I", $thing);
   $thing = preg_replace("/\xD2/", "O", $thing);
   $thing = preg_replace("/\xD9/", "U", $thing);

   $thing = preg_replace("/\xE1/", "a", $thing);
   $thing = preg_replace("/\xE9/", "e", $thing);
   $thing = preg_replace("/\xED/", "i", $thing);
   $thing = preg_replace("/\xF3/", "o", $thing);
   $thing = preg_replace("/\xFA/", "u", $thing);
   $thing = preg_replace("/\xFD/", "y", $thing);

   $thing = preg_replace("/\xC1/", "A", $thing);
   $thing = preg_replace("/\xC9/", "E", $thing);
   $thing = preg_replace("/\xCD/", "I", $thing);
   $thing = preg_replace("/\xD3/", "O", $thing);
   $thing = preg_replace("/\xDA/", "U", $thing);
   $thing = preg_replace("/\xDD/", "Y", $thing);

   $thing = preg_replace("/\xE2/", "a", $thing);
   $thing = preg_replace("/\xEA/", "e", $thing);
   $thing = preg_replace("/\xEE/", "i", $thing);
   $thing = preg_replace("/\xF4/", "o", $thing);
   $thing = preg_replace("/\xFB/", "u", $thing);

   $thing = preg_replace("/\xC2/", "A", $thing);
   $thing = preg_replace("/\xCA/", "E", $thing);
   $thing = preg_replace("/\xCE/", "I", $thing);
   $thing = preg_replace("/\xD4/", "O", $thing);
   $thing = preg_replace("/\xDB/", "U", $thing);

   $thing = preg_replace("/\xE3/", "a", $thing);
   $thing = preg_replace("/\xF1/", "n", $thing);
   $thing = preg_replace("/\xF5/", "o", $thing);

   $thing = preg_replace("/\xC3/", "A", $thing);
   $thing = preg_replace("/\xD1/", "N", $thing);
   $thing = preg_replace("/\xD5/", "O", $thing);

   $thing = preg_replace("/\xE4/", "a", $thing);
   $thing = preg_replace("/\xEB/", "e", $thing);
   $thing = preg_replace("/\xEF/", "i", $thing);
   $thing = preg_replace("/\xF6/", "o", $thing);
   $thing = preg_replace("/\xFC/", "u", $thing);
   $thing = preg_replace("/\xFF/", "y", $thing);

   $thing = preg_replace("/\xC4/", "A", $thing);
   $thing = preg_replace("/\xCB/", "E", $thing);
   $thing = preg_replace("/\xCF/", "I", $thing);
   $thing = preg_replace("/\xD6/", "O", $thing);
   $thing = preg_replace("/\xDC/", "U", $thing);
   $thing = preg_replace("/\x9f/", "Y", $thing);

   $thing = preg_replace("/\xE7/", "c", $thing);
   $thing = preg_replace("/\xC7/", "C", $thing);

   return $thing;
 }

 Maybe it's useful for others, it's along the lines of htmlspecialchars(); etc...

 -lindsey


 --
 PHP Development 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]



-- 
PHP Development 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-DEV] Function suggestion

2001-04-10 Thread Lindsey Simon

Oh yes, and I see I forgot to excape the x in the first five..

Rasmus Lerdorf in message Re: [PHP-DEV] Function suggestion (Tue, 04/10 12:43):

 Using str_replace() would speed this function up by an order of magnitude.
 
 On Tue, 10 Apr 2001, Lindsey Simon wrote:
 
  I'm not positive I'm mailing to the right list, but I have a function that might 
be useful
  to others. I often use php to retrieve a name from a database and then let a user 
upload a
  file and I name that file by as $user.mp3(in this case). I need to convert all of 
the
  international characters to a standard character for this since different OS's send
  requests for filenames with non-standard standards...
 
  so here goes:
 
  function intl2plain ($thing) {
$thing = preg_replace("/xE0/", "a", $thing);
$thing = preg_replace("/xE8/", "e", $thing);
$thing = preg_replace("/xEC/", "i", $thing);
$thing = preg_replace("/xF2/", "o", $thing);
$thing = preg_replace("/xF9/", "u", $thing);
 
$thing = preg_replace("/\xC0/", "A", $thing);
$thing = preg_replace("/\xC8/", "E", $thing);
$thing = preg_replace("/\xCC/", "I", $thing);
$thing = preg_replace("/\xD2/", "O", $thing);
$thing = preg_replace("/\xD9/", "U", $thing);
 
$thing = preg_replace("/\xE1/", "a", $thing);
$thing = preg_replace("/\xE9/", "e", $thing);
$thing = preg_replace("/\xED/", "i", $thing);
$thing = preg_replace("/\xF3/", "o", $thing);
$thing = preg_replace("/\xFA/", "u", $thing);
$thing = preg_replace("/\xFD/", "y", $thing);
 
$thing = preg_replace("/\xC1/", "A", $thing);
$thing = preg_replace("/\xC9/", "E", $thing);
$thing = preg_replace("/\xCD/", "I", $thing);
$thing = preg_replace("/\xD3/", "O", $thing);
$thing = preg_replace("/\xDA/", "U", $thing);
$thing = preg_replace("/\xDD/", "Y", $thing);
 
$thing = preg_replace("/\xE2/", "a", $thing);
$thing = preg_replace("/\xEA/", "e", $thing);
$thing = preg_replace("/\xEE/", "i", $thing);
$thing = preg_replace("/\xF4/", "o", $thing);
$thing = preg_replace("/\xFB/", "u", $thing);
 
$thing = preg_replace("/\xC2/", "A", $thing);
$thing = preg_replace("/\xCA/", "E", $thing);
$thing = preg_replace("/\xCE/", "I", $thing);
$thing = preg_replace("/\xD4/", "O", $thing);
$thing = preg_replace("/\xDB/", "U", $thing);
 
$thing = preg_replace("/\xE3/", "a", $thing);
$thing = preg_replace("/\xF1/", "n", $thing);
$thing = preg_replace("/\xF5/", "o", $thing);
 
$thing = preg_replace("/\xC3/", "A", $thing);
$thing = preg_replace("/\xD1/", "N", $thing);
$thing = preg_replace("/\xD5/", "O", $thing);
 
$thing = preg_replace("/\xE4/", "a", $thing);
$thing = preg_replace("/\xEB/", "e", $thing);
$thing = preg_replace("/\xEF/", "i", $thing);
$thing = preg_replace("/\xF6/", "o", $thing);
$thing = preg_replace("/\xFC/", "u", $thing);
$thing = preg_replace("/\xFF/", "y", $thing);
 
$thing = preg_replace("/\xC4/", "A", $thing);
$thing = preg_replace("/\xCB/", "E", $thing);
$thing = preg_replace("/\xCF/", "I", $thing);
$thing = preg_replace("/\xD6/", "O", $thing);
$thing = preg_replace("/\xDC/", "U", $thing);
$thing = preg_replace("/\x9f/", "Y", $thing);
 
$thing = preg_replace("/\xE7/", "c", $thing);
$thing = preg_replace("/\xC7/", "C", $thing);
 
return $thing;
  }
 
  Maybe it's useful for others, it's along the lines of htmlspecialchars(); etc...
 
  -lindsey
 
 
  --
  PHP Development 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]
 

-- 
PHP Development 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]