<?php
error_reporting(-1);
ini_set('display_errors', TRUE);
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
date_default_timezone_set('Europe/Berlin');
$string = "B 20:15, H 21:00, H 21:00, H 21:15, M 22:30, H 21:30, R 00:00, R 23:30, M 22:30, M 22:45, M 22:45, H 21:30, R 23:35";
$ergebnis = explode(", ", $string);
asort($ergebnis);
$ergebnis1 = array_unique($ergebnis, SORT_STRING);
$string_neu = "";
foreach($ergebnis1 AS $a){
if (!strpos($string_neu, substr($a, 0, 1))) {
$string_neu .= $a .', ';
}
}
echo substr($string_neu, 0, -2);
- Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- B 20:15, H 21:00, M 22:30, R 00:00
preferences:
106.45 ms | 406 KiB | 5 Q