[PHP] ucwords()?

2002-09-11 Thread Tommi Virtanen

Hi!

I'll try to convert field first char to upper by using ucwords(). Well,
this doesn't
seem to work correct. 

Well maybe error came, because that characteres are not standard (they
are special characterers, finnish language). 

Example:

$work_text = perhepäivähoitaja;

$work_text = ucwords (strtolower ($work_text);

print $work_name - PerhepäIväHoitaja). Every char after finnish-ä is
upper.


How I can correct this error??

gustavus 



RE: [PHP] ucwords()? and åäö

2002-09-11 Thread Ville Mattila

I can't say correct answer to this, but want also notify that
strtoupper() -function doesn't affect to those special charters å, ä and ö
that are very common in Finnish language.

Ville


-Original Message-
From: Tommi Virtanen [mailto:[EMAIL PROTECTED]]
Sent: 11. syyskuuta 2002 17:14
To: [EMAIL PROTECTED]
Subject: [PHP] ucwords()?


Hi!

I'll try to convert field first char to upper by using ucwords(). Well,
this doesn't
seem to work correct.

Well maybe error came, because that characteres are not standard (they
are special characterers, finnish language).

Example:

$work_text = perhepäivähoitaja;

$work_text = ucwords (strtolower ($work_text);

print $work_name - PerhepäIväHoitaja). Every char after finnish-ä is
upper.


How I can correct this error??

gustavus


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




Re: [PHP] ucwords()? and åäö

2002-09-11 Thread Zak Greant

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Here is a quick replacement script* for ucwords() that can be made to handle 
accented characters or interesting casing rules. It is a bit uppercase happy 
- - uppercasing any letter that comes after a non-letter character.

*(Taken from the PHP Functions Essential Reference 
(http://fooassociates.com/phpfer/))

?php
function custom_ucwords($map, $string) {
   // A state variable that tracks if we are inside
   // or outside a block of word characters
   $inside_word = TRUE;

   for ($index = 0; $index  strlen($string); ++$index) {

  // If the current character is a key for the map array,
  // we know that the current character is a word character
  $is_chr = isset($map[$string[$index]]);

  /* If the last character was not a word character
   * but the current character is, convert the
   * current character to uppercase
  */
  if (! $inside_word  $is_chr) {
  $string[$index] = $map[$string[$index]];
  }

  // Track whether this character is a word or a non-word character
  // for the next iteration of the loop
  $inside_word = $is_chr;
   }

   return $string;
}

// A map for English characters
$map = array(
   'a' = 'A', 'b' = 'B', 'c' = 'C', 'd' = 'D',
   'e' = 'E', 'f' = 'F', 'g' = 'G', 'h' = 'H',
   'i' = 'I', 'j' = 'J', 'k' = 'K', 'l' = 'L',
   'm' = 'M', 'n' = 'N', 'o' = 'O', 'p' = 'P',
   'q' = 'Q', 'r' = 'R', 's' = 'S', 't' = 'T',
   'u' = 'U', 'v' = 'V', 'w' = 'W', 'x' = 'X',
   'y' = 'Y', 'z' = 'Z'
);

$string = _JABBERWOCKY_
and, has thou slain the jabberwock?br /
come to my arms, my beamish boy!br /
o frabjous day! callooh! callay!br /
he chortled in his joy.br /
_JABBERWOCKY_;

echo custom_ucwords($map, $string);
?


Cheers!
- --zak



On September 11, 2002 08:27, Ville Mattila wrote:
 I can't say correct answer to this, but want also notify that
 strtoupper() -function doesn't affect to those special charters å, ä and ö
 that are very common in Finnish language.

 Ville


 -Original Message-
 From: Tommi Virtanen [mailto:[EMAIL PROTECTED]]
 Sent: 11. syyskuuta 2002 17:14
 To: [EMAIL PROTECTED]
 Subject: [PHP] ucwords()?


 Hi!

 I'll try to convert field first char to upper by using ucwords(). Well,
 this doesn't
 seem to work correct.

 Well maybe error came, because that characteres are not standard (they
 are special characterers, finnish language).

 Example:

 $work_text = perhepäivähoitaja;

 $work_text = ucwords (strtolower ($work_text);

 print $work_name - PerhepäIväHoitaja). Every char after finnish-ä is
 upper.


 How I can correct this error??

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

iD8DBQE9f6nlb6QONwsK8bIRAhANAJ9Xab9JmsjKxlp+KF01822QmK8zFQCbBXW+
92J2XRJgKmRXRAlhp7QbwTM=
=QEMR
-END PGP SIGNATURE-


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




[PHP] ucwords() usage QUICKIE

2002-06-14 Thread Daniel Negron/KBE

Hi All,

 I am trying to figure out how to use ucwords here :
if (submit)
$db = mysql_connect($dbhost,$dbuname,$dbpass);
  mysql_select_db($dbname,$db);
  ucwords($sql)Is this correct ?
  $sql = INSERT INTO $prefix;
  $sql .= (first, last, email, company, address, city, state, zip,
phone, fax, mobile, comments);
  $sql .= VALUES;
  $sql .= ('$first', '$last', '$email', '$company', '$address',
'$city', '$state', '$zip', '$phone', '$fax', '$mobile', '$comments');
also can you do this  field level ?


Danny


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




RE: [PHP] ucwords() usage QUICKIE

2002-06-14 Thread Lazor, Ed

Looks like it, but you're missing the semi-colon at the end of the line.

 -Original Message-
 From: Daniel Negron/KBE [mailto:[EMAIL PROTECTED]]
 Sent: Friday, June 14, 2002 2:06 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] ucwords() usage QUICKIE
 
 
 Hi All,
 
  I am trying to figure out how to use ucwords here :
 if (submit)
 $db = mysql_connect($dbhost,$dbuname,$dbpass);
   mysql_select_db($dbname,$db);
   ucwords($sql)Is this correct ?
   $sql = INSERT INTO $prefix;
   $sql .= (first, last, email, company, address, 
 city, state, zip,
 phone, fax, mobile, comments);
   $sql .= VALUES;
   $sql .= ('$first', '$last', '$email', '$company', 
 '$address',
 '$city', '$state', '$zip', '$phone', '$fax', '$mobile', '$comments');
 also can you do this @ field level ?
 
 
 Danny
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.   

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




Re: [PHP] ucwords() usage QUICKIE

2002-06-14 Thread Julie Meloni

DNK  I am trying to figure out how to use ucwords here :
DNK if (submit)
DNK $db = mysql_connect($dbhost,$dbuname,$dbpass);
DNK   mysql_select_db($dbname,$db);
DNK   ucwords($sql)Is this correct ?
DNK   $sql = INSERT INTO $prefix;
DNK   $sql .= (first, last, email, company, address, city, state, zip,
DNK phone, fax, mobile, comments);
DNK   $sql .= VALUES;
DNK   $sql .= ('$first', '$last', '$email', '$company', '$address',
DNK '$city', '$state', '$zip', '$phone', '$fax', '$mobile', '$comments');
DNK also can you do this @ field level ?

Currently, you are ucwords-ing an empty string.  That being said, I'm
not sure what you are trying to do anyway. ucwords() upper-cases the first letter of 
words in a string.
(http://www.php.net/manual/en/function.ucwords.php)

such as:

$string = this is a test;
$newstring = ucwords($string);
echo $newstring // This Is A Test


- Julie

-- Julie Meloni
-- [EMAIL PROTECTED]
-- www.thickbook.com

Find Sams Teach Yourself MySQL in 24 Hours at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


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




Re: [PHP] ucwords() usage QUICKIE

2002-06-14 Thread 1LT John W. Holmes

You pass a string to the function and it returns a string with each word
starting with an uppercase.

$string = hello world;

$new_string = ucwords($string);

echo $new_string; // Displays 'Hello World'

---John Holmes...

- Original Message -
From: Daniel Negron/KBE [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 14, 2002 5:06 PM
Subject: [PHP] ucwords() usage QUICKIE


 Hi All,

  I am trying to figure out how to use ucwords here :
 if (submit)
 $db = mysql_connect($dbhost,$dbuname,$dbpass);
   mysql_select_db($dbname,$db);
   ucwords($sql)Is this correct ?
   $sql = INSERT INTO $prefix;
   $sql .= (first, last, email, company, address, city, state,
zip,
 phone, fax, mobile, comments);
   $sql .= VALUES;
   $sql .= ('$first', '$last', '$email', '$company', '$address',
 '$city', '$state', '$zip', '$phone', '$fax', '$mobile', '$comments');
 also can you do this @ field level ?


 Danny


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



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




Re: [PHP] ucwords added functionality?

2001-09-24 Thread Steve Edberg

I came up with a function to to that last month; see the PHP archives:

http://marc.theaimsgroup.com/?l=php-generalm=99778991424637w=2

-steve


At 11:20 PM -0400 9/23/01, Jack Dempsey wrote:
i could roll my own, and for now will just use a str_replace after ucwords,
but would it be possible to add an optional parameter to ucwords which would
be an array of words to skip? i would think this would be useful to
many.

any thoughts?


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

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




[PHP] ucwords added functionality?

2001-09-23 Thread Jack Dempsey

i could roll my own, and for now will just use a str_replace after ucwords,
but would it be possible to add an optional parameter to ucwords which would
be an array of words to skip? i would think this would be useful to
many.

any thoughts?


-- 
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] ucwords Except 'The' 'And' etc?

2001-08-14 Thread Steve Edberg

I know, I know, I have a lot of work to do...I shouldn't be doing 
this. I did get to play with PCRE regexps here, though...lotsa cool 
features over eregs!. Anyway, here's a *** NEW!!! IMPROVED!!! *** 
version of smart_ucwords(), that's probably way too much overkill. I 
did some quick tests, seems to work. Beware of email-induced 
line-wrapping, particularly in the comment black  quoted strings:

?php

function smart_ucwords($String, $ForceCase=1, $CapitalizeTrailing=1) {


#
#  A more sophisticated approach to title-casing.
#
## PARAMETERS 
##
#
#  $String  string   Input string.
#  $ForceCase   0|1  If true, will force title case (only 
first letter
#capitalized, no matter what case the 
string is in.
#  $CaptializeTrailing  0|1  If true, will capitalize a normally-excepted
#word if it is the last word in the 
string. So, a
#string like 'Shot In the Dark, A' 
works properly.
#
## USAGE NOTES 
#
#
#  The Exception List words should be in the case you desire; 
normally this will
#  be lowercase.
#
#  The Invariant List contains words and titles (eg; NASA, MySQL, PostGreSQL,
#  eBusiness) whose capitalization should be fixed, no matter what.
#
#  If one of these arrays is not to be used, simply set it to array().
#
## MODIFICATION HISTORY 

#
#  14 august 2001: S. Edberg, UCDavis [EMAIL PROTECTED]
#  Original
#


$EXCEPTION_LIST = array(
   'a', 'an', 'and', 'at', 'but', 'for', 'nor', 'or', 'some', 
'the', 'to', 'with'
);
   
$INVARIANT_LIST = array(
   'NASA', 'MySQL', 'PostGreSQL', 'eBusiness'
);
   
#  First, strip  save leading  trailing whitespace

preg_match(
   '/^(\s*?)(.*)(\s*)$/U',
   ($ForceCase ? strtolower($String) : $String),
   $StringParts
);

#  Replace exception words

$String = ucwords($StringParts[2].($CapitalizeTrailing ? '' : ' '));

foreach ($EXCEPTION_LIST as $Word) {
   $String = preg_replace(/(\s+)$Word(\s+)/i, \\1$Word\\2, $String);
}

#  Replace invariants

$String =  $String ;
   
foreach ($INVARIANT_LIST as $Word) {
   $String = preg_replace(/(\s+)$Word(\s+)/i, \\1$Word\\2, $String);
}

#  Replace whitespace and return

return $StringParts[1].trim($String).$StringParts[3];

}

?


At 4:09 PM -0500 8/13/01, Jeff Oien wrote:
Fabulous. Thanks to Steve and Mark. Exactly what I needed.
Jeff Oien

  Something like this, perhaps (untested):

  I needed this too so I just tested it.

  function smart_ucwords($String)
  {
  
 $ExceptionList = array('the', 'an', 'a'); # should all be in
  lowercase
  
 $String = ucwords(strtolower(ltrim($String))); # LINE A
  
 foreach ($ExceptionList as $Word)
 {
 $String = eregi_replace([[:space:]]+$Word[[:space:]]+,
  $Word, $String);
 }


  this line should be more like:
  $String = eregi_replace(([[:space:]]+).$Word.([[:space:]]+),
  \\1.$Word.\\2, $String);

 return $String; # LINE B
  
  }

  thanks!
  - Mark
  


-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

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




[PHP] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Jeff Oien

Is there a prewritten function for capitalizing the first letter of each
word in a string except for the common words you wouldn't want
to capitalize in a title? Like

Come Learn the Facts From an Industry Leader 

Thanks.
Jeff Oien

-- 
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] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Boget, Chris

 Is there a prewritten function for capitalizing the first 
 letter of each word in a string except for the common 
 words you wouldn't want to capitalize in a title? Like
 Come Learn the Facts From an Industry Leader 

None that I've seen.
But it wouldn't be hard to write a function that takes a 
string, passes that string to ucwords() and then you can
run through a pre-defined array and just do an ereg_replace()
on those words you want to remain lowercase...

Or something like that...

Chris



Re: [PHP] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Richard Baskett

http://www.php.net/manual/en/function.ucwords.php

You can read all about the limit of this function, but this is the closest
thing to what you're looking for.

Rick

 Is there a prewritten function for capitalizing the first letter of each
 word in a string except for the common words you wouldn't want
 to capitalize in a title? Like
 
 Come Learn the Facts From an Industry Leader
 
 Thanks.
 Jeff Oien


-- 
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] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Steve Edberg

Something like this, perhaps (untested):

function smart_ucwords($String)
{

$ExceptionList = array('the', 'an', 'a'); # should all be in lowercase

$String = ucwords(strtolower(ltrim($String))); # LINE A

foreach ($ExceptionList as $Word)
{
$String = eregi_replace([[:space:]]+$Word[[:space:]]+, 
$Word, $String);
}

return $String; # LINE B

}

This will leave the exception word capitalized if it is the first 
word in the $String (as it should be), or if it is the last work in 
the $String (unlikely). If you want to handle cases where the 
exception word comes at the end of the string, just replace LINE A 
above with

$String = ucwords(strtolower($String)).' ';

and LINE B with

return rtrim($String);

Of course, there will be exceptions that are near-impossible to 
programmatically determine, eg;
'Dr. Martin van Hooten Hears a Who'

in this case, van should be lower case, since it isn't referring to a 
medium-capacity box-like automobile, tennis shoe brand, or naval 
vanguard.

-steve



At 11:07 AM -0500 8/13/01, Boget, Chris [EMAIL PROTECTED] wrote:
   Is there a prewritten function for capitalizing the first
  letter of each word in a string except for the common
  words you wouldn't want to capitalize in a title? Like
  Come Learn the Facts From an Industry Leader

None that I've seen.
But it wouldn't be hard to write a function that takes a
string, passes that string to ucwords() and then you can
run through a pre-defined array and just do an ereg_replace()
on those words you want to remain lowercase...

Or something like that...

Chris

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
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] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Mark Maggelet

Something like this, perhaps (untested):

I needed this too so I just tested it.

function smart_ucwords($String)
{

   $ExceptionList = array('the', 'an', 'a'); # should all be in
lowercase

   $String = ucwords(strtolower(ltrim($String))); # LINE A

   foreach ($ExceptionList as $Word)
   {
   $String = eregi_replace([[:space:]]+$Word[[:space:]]+,
$Word, $String);
   }


this line should be more like:
$String = eregi_replace(([[:space:]]+).$Word.([[:space:]]+),
\\1.$Word.\\2, $String);

   return $String; # LINE B

}

thanks!
- Mark


--
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] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Jeff Oien

Fabulous. Thanks to Steve and Mark. Exactly what I needed.
Jeff Oien

 Something like this, perhaps (untested):
 
 I needed this too so I just tested it.
 
 function smart_ucwords($String)
 {
 
  $ExceptionList = array('the', 'an', 'a'); # should all be in 
 lowercase
 
  $String = ucwords(strtolower(ltrim($String))); # LINE A
 
  foreach ($ExceptionList as $Word)
  {
  $String = eregi_replace([[:space:]]+$Word[[:space:]]+, 
 $Word, $String);
  }
 
 
 this line should be more like:
 $String = eregi_replace(([[:space:]]+).$Word.([[:space:]]+), 
 \\1.$Word.\\2, $String);
 
  return $String; # LINE B
 
 }
 
 thanks!
 - Mark
 

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