namespace App\Http\Controllers;
use Class\With\Namespace;
$obj = new \Class\With\Namespace;
$static = \Class\With\Namespace::staticMethod();
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadHTML(mb_convert_encoding($snapshot, 'HTML-ENTITIES', 'UTF-8'));
$cities = ['Moscow', 'London', 'NY', 'LA'];
sort($cities);
$citiesByLetters = [];
foreach ($cities as $city) {
$citiesByLetters[$city[0]][] = $city;
}
foreach ($citiesByLetters as $letter => $cities) {
echo '<div id="letter-'.$letter.'">';
foreach ($cities as $city) {
echo '<div class="city-el">'.$city.'</div>';
}
echo '</div>';
}