Dieter Raber: 2 dim array nach namen sort.

Beitrag lesen

Hallo Harty,

Wie waer's damit:
$foo[0][0] = '051';
$foo[0][1] = 'Paul';
$foo[0][2] = 'xyz';
$foo[1][0] = '112';
$foo[1][1] = 'Freddy';
$foo[1][2] = 'xyz';
$foo[2][0] = '018';
$foo[2][1] = 'Marta';
$foo[2][2] = 'xyz';
print_r($foo);
foreach($foo as $key => $value)
{
  $bar[$foo[$key][1]] = $foo[$key];
}
ksort($bar);
$foo = array();
foreach($bar as $key => $value)
{
  $foo[] = $value;
}
print_r($foo);

Das kann man wahrscheinlich noch viel effizienter machen, aber das sit das erste, was mir eingefallen ist.

Dieter