note 93763 added to function.ucfirst

From: Date: Sun, 27 Sep 2009 00:18:45 +0000
Subject: note 93763 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-161103@lists.php.net to get a copy of this message
For lithuanian text with utf-8 encoding I use two functions (thanks „mattalexxpub at gmail dot com“ and Svetoslav Marinov) function my_ucfirst($string, $e ='utf-8') { if (function_exists('mb_strtoupper') && function_exists('mb_substr') && !empty($string)) { $string = mb_strtolower($string, $e); $upper = mb_strtoupper($string, $e); preg_match('#(.)#us', $upper, $matches); $string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $e), $e); } else { $string = ucfirst($string); } return $string; } function sentence_case($string) { $sentences = preg_split('/([.?!]+)/', $string, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE); $new_string = ''; foreach ($sentences as $key => $sentence) { $new_string .= ($key & 1) == 0? my_ucfirst(strtolower(trim($sentence))) : $sentence.' '; } return trim($new_string); } ---- Server IP: 208.69.120.35 Probable Submitter: 77.221.72.71 ---- Manual Page -- http://www.php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/93763 Del: integrated -- https://master.php.net/note/delete/93763/integrated Del: useless -- https://master.php.net/note/delete/93763/useless Del: bad code -- https://master.php.net/note/delete/93763/bad+code Del: spam -- https://master.php.net/note/delete/93763/spam Del: non-english -- https://master.php.net/note/delete/93763/non-english Del: in docs -- https://master.php.net/note/delete/93763/in+docs Del: other reasons-- https://master.php.net/note/delete/93763 Reject -- https://master.php.net/note/reject/93763 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161103) next »