- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
<?php
$str = 'улица ленина';
$array = explode(' ', $str);
if(count($array) == 0)
{
$tire = true;
$array = explode('-', $str);
}
foreach($array as $value)
{
$start = mb_substr($value, 0, 1, 'UTF-8');
$end = mb_substr($value, 1, mb_strlen($value), 'UTF-8');
$start = mb_strtoupper($start, 'UTF-8');
if($tire) $text .= $start.$end.'-';
else $text .= $start.$end.' ';
}
if($tire) $text = substr($text, 0, -1);
else $text = trim($text);
echo $text;
?>