1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <?php
//dans une class Tool
class Tool{
public function mb_ucfirst($str, $encoding = null) {
if (!$encoding) $encoding = mb_internal_encoding();
return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $encoding);
}
}
$tool=new Tool();
mb_internal_encoding('UTF-8');
$mots=array();
$mots[]='à faire';
$mots[]='éric';
$mots[]='ça';
$mots[]='ère';
$mots[]='île';
$mots[]='saucisson';
$mots[]='patricia';
$mots[]='féodor';
$mots_initiales=array();
foreach($mots as $mot){
$mots_initiales[]= $tool->mb_ucfirst($mot);
}
echo '<pre>';
print_r($mots_initiales);
echo '</pre>';
/*
Array
(
[0] => À faire
[1] => Éric
[2] => Ça
[3] => Ère
[4] => Île
[5] => Saucisson
[6] => Patricia
[7] => Féodor
)
*/ |