[Typo3-dev] Splitting array acording to alphabet (Solution)

Georg Ringer georg-ringer at gmx.at
Fri Jun 17 12:58:46 CEST 2005


Hello,

thanks to Arne & Michael but I got the solution from a friend who is "a
little" bit better in php than me =>

<?
$namen =
array(Andy,Peter,Ziegler,Meier,Dengler,Mueller,Franske,Hans,Anton,Arber,Xsav
er,Lempke,Koeler,Merkel,Kohl,Goekmen,Neumann,Geinzer,Kunstmann,Schroeder,Cra
sselt);
sort($namen);
$az = array (ABC,DEF,GHI,JKL,MNO,PQR,STU,VWX,YZ);
$x = 0;
foreach($namen as $name) {
if(substr($name, 0,1) == substr($az[$x], 0,1) || substr($name, 0,1) ==
substr($az[$x], 1,2) || substr($name, 0,1) == substr($az[$x], 2,3)) {
if($az[$x] != $alt) {
echo "<br /><big><b>".$az[$x]."</b></big><br />";
$alt = $az[$x];
$x = $x + 1;
}
}
echo $name."<br />";
}
?>
===========

Georg






More information about the TYPO3-dev mailing list