[Typo3-dev] Splitting array acording to alphabet
Georg Ringer
georg-ringer at gmx.at
Fri Jun 17 15:25:22 CEST 2005
And a problem again:
You can easily see it at:
http://inside.eventshooters.com/typo3conf/ext/rg_zitate/pi1/test.php
Kant, Immanuel => GHI
Waggerl, Karl Heinrich => STU
Wilde, Oscar => STU
Wilder, Thornton => STU
but why???
The records & code:
.......
$data[] = array('nname' => 'Auerbach', 'vname' => 'Berthold', 'uid' => 20);
$data[] = array('nname' => 'Bloch', 'vname' => 'Ernst', 'uid' => 24);
$data[] = array('nname' => 'Shaw', 'vname' => 'George Bernard', 'uid' =>
19);
$data[] = array('nname' => 'Wilde', 'vname' => 'Oscar', 'uid' => 12);
$data[] = array('nname' => 'Wilder', 'vname' => 'Thornton', 'uid' => 38);
$az = array ('ABC','DEF','GHI','JKL','MNO','PQR','STU','VWX','YZ');
$x = 0;
foreach($data as $name) {
if(substr($name[nname], 0,1) == substr($az[$x], 0,1) ||
substr($name[nname], 0,1) == substr($az[$x], 1,2) || substr($name[nname],
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[nname].', '.$name[vname]."<br />";
}
Please help me!
many thanks!
georg
More information about the TYPO3-dev
mailing list