Hallo Christian,

Ich mache das eigentlich immer mit array_multisort.
http://ch2.php.net/manual/en/function.array-multisort.php

Beispiel

<?php

$data = array(
    array('uid' => '2', 'text' => 'test 2'),
    array('uid' => '86', 'text' => 'test 86'),
    array('uid' => '26', 'text' => 'test 26'),
    array('uid' => '32', 'text' => 'test 32'),
    array('uid' => '22', 'text' => 'test 22'),
    array('uid' => '12', 'text' => 'test 12'),
    );

foreach ($data as $key => $row) {
    $uid[$key]  = $row['uid'];
}

print_r($uid);

array_multisort($uid, SORT_ASC, $data);

print_r($data);

?>

Gruss
Roland


On 04.07.2012 19:33, Christian Tauscher wrote:
Hallo Zusammen.

Steh immer wieder mal vor dem Problem:

Hab aus der DB ein Array zurück bekommen:

0 => { 'uid' => 1, ... }
1 => { 'uid' => 12, ... }
2 => { 'uid' => 75, ... }
3 => { 'uid' => 86, ... }

Schön.

Dazu hab ich eine Liste 86,1,75,12 an uid. Die datensätze die der User
auswählte.

Ich sortiere das ganz bisher so, das ich die liste mit explode in ein
array überführe und dann das zu sortierende Array und das DB Array in
einer verschachtelten Schleife neu sortiere in dem ich $key ==
$db['uid'] prüfe.

Das ist natürlich ein verdammter Aufwand weil jedes Element gegen jedes
geprüft wird.

Aber es funktioniert.

An die Informatiker hier im Forum:
Gibt es hier nix besseres, schnelleres, ressourcen schonendes.
Vielleicht sogar schon im Core von TYPO3 implementiert?
So was muss doch ständig gemacht werden?

Danke für Tipps

Christian.
_______________________________________________
TYPO3-german mailing list
TYPO3-german@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german


_______________________________________________
TYPO3-german mailing list
TYPO3-german@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german

Antwort per Email an