SELFPHP: Version 5.8.2 Befehlsreferenz - Tutorial – Kochbuch – Forum für PHP Einsteiger und professionelle Entwickler

SELFPHP


Professional CronJob-Service

Suche



CronJob-Service    
bei SELFPHP mit ...



 + minütlichen Aufrufen
 + eigenem Crontab Eintrag
 + unbegrenzten CronJobs
 + Statistiken
 + Beispielaufrufen
 + Control-Bereich

Führen Sie mit den CronJobs von SELFPHP zeitgesteuert Programme auf Ihrem Server aus. Weitere Infos



:: Buchempfehlung ::

Das Zend Framework

Das Zend Framework zur Buchempfehlung
 

:: Anbieterverzeichnis ::

Globale Branchen

Informieren Sie sich über ausgewählte Unternehmen im Anbieterverzeichnis von SELFPHP  

 

:: Newsletter ::

Abonnieren Sie hier den kostenlosen SELFPHP Newsletter!

Vorname: 
Name:
E-Mail:
 
 

Zurück   PHP Forum > SELFPHP > PHP Grundlagen

PHP Grundlagen Hier kann über grundlegende Probleme oder Anfängerschwierigkeiten diskutiert werden

 
 
Themen-Optionen Ansicht
  #1  
Alt 22.01.2008, 21:05:48
Leblondi Leblondi ist offline
Anfänger
 
Registriert seit: Jan 2008
Beiträge: 5
Mehrdimensionales Array sortieren

Hallo,

ich habe ein Problem mit der Sortierung des folgenden Array.


Die Daten kommen aus einer Datenbank und werden mit einer Schleife so in das Array geschrieben:
PHP-Code:
$array_Room[$i][$j][$OutputOrder[$key][0]][$OutputOrder[$key][1]][$key] = $val
über das Array
PHP-Code:
$OutputOrder[$key
wird ein Sortierschlüssel zurückgegeben.

Als Ergebnis bekomme ich bei Auslesen des Array´s folgendes zurück:

0 / 0 / 5 / 1 / RoomID / 1
0 / 0 / 5 / 2 / Description / Doppelzimmer, D / WC, Radio, TV, Telefon, Haarföhn, teilweise mit Balkon
0 / 0 / 10 / 1 / AdultDay_Price / 95.00
0 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
0 / 0 / 20 / 1 / 3Person_Price /
0 / 0 / 20 / 2 / 4Person_Price /
0 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
0 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
0 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
0 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
0 / 0 / 1 / 1 / TimeDescription / Sportwochen
0 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
0 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
1 / 0 / 5 / 1 / RoomID / 2
1 / 0 / 5 / 2 / Description / Doppelzimmer, Bad / WC, Radio, TV, Telefon, Haarföhn, teilweise mit Balkon
1 / 0 / 10 / 1 / AdultDay_Price / 97.00
1 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
1 / 0 / 20 / 1 / 3Person_Price /
1 / 0 / 20 / 2 / 4Person_Price /
1 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
1 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
1 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
1 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
1 / 0 / 1 / 1 / TimeDescription / Sportwochen
1 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
1 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
2 / 0 / 5 / 1 / RoomID / 3
2 / 0 / 5 / 2 / Description / Einbettzimmer, D / WC, Radio, TV, Telefon, Haarföhn
2 / 0 / 10 / 1 / AdultDay_Price / 95.00
2 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
2 / 0 / 20 / 1 / 3Person_Price /
2 / 0 / 20 / 2 / 4Person_Price /
2 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
2 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
2 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
2 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
2 / 0 / 1 / 1 / TimeDescription / Sportwochen
2 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
2 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
3 / 0 / 5 / 1 / RoomID / 4
3 / 0 / 5 / 2 / Description / Studiozimmer, Bad / WC, Radio, TV, Telefon, Sitzecke
3 / 0 / 10 / 1 / AdultDay_Price / 100.00
3 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
3 / 0 / 20 / 1 / 3Person_Price /
3 / 0 / 20 / 2 / 4Person_Price /
3 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
3 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
3 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
3 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
3 / 0 / 1 / 1 / TimeDescription / Sportwochen
3 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
3 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
4 / 0 / 5 / 1 / RoomID / 5
4 / 0 / 5 / 2 / Description / Appartment A 45 m2, 3 Pers. € 55,- 4 Pers. € 47,- pro Tag mit HP / Kinder
4 / 0 / 10 / 1 / AdultDay_Price / 107.00
4 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
4 / 0 / 20 / 1 / 3Person_Price / 55.00
4 / 0 / 20 / 2 / 4Person_Price / 47.00
4 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
4 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
4 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
4 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
4 / 0 / 1 / 1 / TimeDescription / Sportwochen
4 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
4 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
5 / 0 / 5 / 1 / RoomID / 6
5 / 0 / 5 / 2 / Description / Appartment B 48 m2, 3 Pers. € 63,- 4 Pers. € 55,- pro Tag mit HP / Kinder
5 / 0 / 10 / 1 / AdultDay_Price / 117.00
5 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
5 / 0 / 20 / 1 / 3Person_Price / 63.00
5 / 0 / 20 / 2 / 4Person_Price / 55.00
5 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
5 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
5 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
5 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
5 / 0 / 1 / 1 / TimeDescription / Sportwochen
5 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
5 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00

Nun möchte ich das ganze nach den Spalten 3 (0 / 0 / 1 / 1 /), 1 (0 / 0 / 1 / 1 /) und 4 (0 / 0 / 1 / 1 /) sortieren, allerdings schaut das Ergebnis dann leider so aus: (hier wurde nur nach Spalte 3 (0 / 0 / 1 / 1 /) sortiert)

4 / 0 / 5 / 1 / RoomID / 5
4 / 0 / 5 / 2 / Description / Appartment A 45 m2, 3 Pers. € 55,- 4 Pers. € 47,- pro Tag mit HP / Kinder
4 / 0 / 10 / 1 / AdultDay_Price / 107.00
4 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
4 / 0 / 20 / 1 / 3Person_Price / 55.00
4 / 0 / 20 / 2 / 4Person_Price / 47.00
4 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
4 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
4 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
4 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
4 / 0 / 1 / 1 / TimeDescription / Sportwochen
4 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
4 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
5 / 0 / 5 / 1 / RoomID / 6
5 / 0 / 5 / 2 / Description / Appartment B 48 m2, 3 Pers. € 63,- 4 Pers. € 55,- pro Tag mit HP / Kinder
5 / 0 / 10 / 1 / AdultDay_Price / 117.00
5 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
5 / 0 / 20 / 1 / 3Person_Price / 63.00
5 / 0 / 20 / 2 / 4Person_Price / 55.00
5 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
5 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
5 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
5 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
5 / 0 / 1 / 1 / TimeDescription / Sportwochen
5 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
5 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
3 / 0 / 5 / 1 / RoomID / 4
3 / 0 / 5 / 2 / Description / Studiozimmer, Bad / WC, Radio, TV, Telefon, Sitzecke
3 / 0 / 10 / 1 / AdultDay_Price / 100.00
3 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
3 / 0 / 20 / 1 / 3Person_Price /
3 / 0 / 20 / 2 / 4Person_Price /
3 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
3 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
3 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
3 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
3 / 0 / 1 / 1 / TimeDescription / Sportwochen
3 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
3 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
2 / 0 / 5 / 1 / RoomID / 3
2 / 0 / 5 / 2 / Description / Einbettzimmer, D / WC, Radio, TV, Telefon, Haarföhn
2 / 0 / 10 / 1 / AdultDay_Price / 95.00
2 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
2 / 0 / 20 / 1 / 3Person_Price /
2 / 0 / 20 / 2 / 4Person_Price /
2 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
2 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
2 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
2 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
2 / 0 / 1 / 1 / TimeDescription / Sportwochen
2 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
2 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
1 / 0 / 5 / 1 / RoomID / 2
1 / 0 / 5 / 2 / Description / Doppelzimmer, Bad / WC, Radio, TV, Telefon, Haarföhn, teilweise mit Balkon
1 / 0 / 10 / 1 / AdultDay_Price / 97.00
1 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
1 / 0 / 20 / 1 / 3Person_Price /
1 / 0 / 20 / 2 / 4Person_Price /
1 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
1 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
1 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
1 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
1 / 0 / 1 / 1 / TimeDescription / Sportwochen
1 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
1 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
0 / 0 / 5 / 1 / RoomID / 1
0 / 0 / 5 / 2 / Description / Doppelzimmer, D / WC, Radio, TV, Telefon, Haarföhn, teilweise mit Balkon
0 / 0 / 10 / 1 / AdultDay_Price / 95.00
0 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
0 / 0 / 20 / 1 / 3Person_Price /
0 / 0 / 20 / 2 / 4Person_Price /
0 / 0 / 30 / 1 / 00ChildDay_Price / 45.00
0 / 0 / 30 / 2 / 00ChildSkipass_Price / 86.50
0 / 0 / 40 / 1 / 10ChildDay_Price / 55.00
0 / 0 / 40 / 2 / 10ChildSkipass_Price / 86.50
0 / 0 / 1 / 1 / TimeDescription / Sportwochen
0 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
0 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00

Richtig wäre es aber so:
0 / 0 / 1 / 1 / TimeDescription / Sportwochen
0 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
0 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00
1 / 0 / 1 / 1 / TimeDescription / Sportwochen
1 / 0 / 1 / 2 / Startdate / 2008-01-12 00:00:00
1 / 0 / 1 / 3 / Enddate / 2008-02-02 00:00:00

...........
0 / 0 / 5 / 1 / RoomID / 1
0 / 0 / 5 / 2 / Description / Doppelzimmer, D / WC, .....
1 / 0 / 5 / 1 / RoomID / 2
1 / 0 / 5 / 2 / Description / Doppelzimmer, Bad / WC, ....
........
0 / 0 / 10 / 1 / AdultDay_Price / 95.00
0 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
1 / 0 / 10 / 1 / AdultDay_Price / 97.00
1 / 0 / 10 / 2 / AdultSkipass_Price / 140.00
......... u.s.w.


Was mache ich hier falsch ? :-(

Zum sortieren verwende ich
PHP-Code:
uksort($array,vergleich); 
Hier noch die Function:
PHP-Code:
$sortcol=  2;  // Spalte nach der sortiert werden soll
$sortord= -1;  // -1 absteigend / +1 aufsteigend

function vergleich($a,$b)
    {
    global 
$sortcol,$sortord  ;
      if(
$a[$sortcol] == $b[$sortcol]) return 0;
      return (
$a[$sortcol] > $b[$sortcol]) ? $sortord : -$sortord ;
    } 

Besten Dank im Voraus für Eure Hilfe

Leblondi

Geändert von Leblondi (22.01.2008 um 21:09:30 Uhr) Grund: falsche Syntax eingefügt
Mit Zitat antworten
 


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind aus.
[IMG] Code ist aus.
HTML-Code ist aus.

Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Mehrdimensionales Array sortieren MrLongbaugh PHP Grundlagen 10 06.03.2008 13:02:47
Mehrdimensionales Array rightround PHP für Fortgeschrittene und Experten 2 23.01.2007 15:49:25
Mehrdimensionales Array sortieren Heppi PHP Grundlagen 21 22.02.2005 13:01:32
Einzelne Daten aus Textdatei Auslesen azubinator PHP Grundlagen 153 17.12.2004 14:36:58
mehrdimensionales Array sortieren blaue-sau PHP Grundlagen 2 18.09.2003 22:02:15


Alle Zeitangaben in WEZ +2. Es ist jetzt 15:19:40 Uhr.


Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.


© 2001-2024 E-Mail SELFPHP OHG, info@selfphp.deImpressumKontakt