Multiarray sortieren

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiarray sortieren

    Hi, hab folgendes Problem

    hab folgendes multiarray:
    PHP Code:
    Array (
     [
    0] => 
      Array ( 
       [
    title] => moep 
       
    [id] => 
       
    [replys] => 
       
    [author] => madpac 
       
    [author_id] => 14 
       
    [lastpost] => madpac 
       
    [lastpost_time] => 1125943523 
       
    [lastpost_id] => 14 
       
    [hits] => 
      

     [
    1] => 
      Array ( 
       [
    title] => o:
       
    [id] => 
       
    [replys] => 
       
    [author] => Pepe 
       
    [author_id] => 
       
    [lastpost] => Pepe 
       
    [lastpost_time] => 1125941884 
       
    [lastpost_id] => 
       
    [hits] => 
      

     [
    2] => 
      Array ( 
       [
    title] => test1 
       
    [id] => 
       
    [replys] => 
       
    [author] => Pepe 
       
    [author_id] => 
       
    [lastpost] => Pepe 
       
    [lastpost_time] => 1125941188 
       
    [lastpost_id] => 
       
    [hits] => 
      
    )

    mein frage: wie bekomm ich es jetzt hin, dass das multiarray nach dem key "lastpost_time" sortiert wird?
    m.f.G. Enerkin
    1123581321

  • #2
    schau mal im handbuch nach usort, vielleicht hilft dir das.

    gruß
    peter
    Nukular, das Wort ist N-u-k-u-l-a-r (Homer Simpson)
    Meine Seite

    Comment


    • #3
      PHP Code:
      foreach($array as $res)
           
      $sort[] = $res['lastpost_time'];

      array_multisort($sortSORT_ASC$array);

      echo 
      "<pre>";
      print_r($array);
      echo 
      "</pre>"
      gruss Chris

      [color=blue]Derjenige, der sagt: "Es geht nicht", soll den nicht stoeren, der's gerade tut."[/color]

      Comment


      • #4
        ok, also so:

        PHP Code:
        foreach($array as $res)
             
        $sort[] = $res['lastpost_time'];

        array_multisort($sortSORT_ASC$array);

        echo 
        "<pre>";
        print_r($array);
        echo 
        "</pre>"
        liefert er mir ja nur ein array mit den timestamps,
        allerdings will ich die struktur von dem array vorher beibehalten, ich will nur die unterarrays nach dem key "lastpost_time" sortieren.
        also d.h. ich hab das große array und er soll die untearrays so sortieren, dass das array mit dem größten wert von "lastpost_time" dann den key 0 vom hauptarray hat.

        weiß allerdings nid wie ich das umsetzen soll?
        hat jmd n denkansatz?

        EDIT: hat sich erledigt ^^, hab die beiden array verwechselt^^ sort mit dem threads.. thx für die hilfe
        Last edited by Enerkin; 06-09-2005, 14:32.
        1123581321

        Comment

        Working...
        X