Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php arrays

Empfohlene Antworten

Hi,

ich hab ne Textdatei wo die Daten eines Datensatzes (aufgeteilt in Zeilen) mit Tabulatur getrennt sind. Wenn ich jetzt zum Beispiel die Textdatei lade und das array[1] ausgeben will, bekomme ich die Ganze Zeile. Die Sache ist, ich will die Zeilen nach der dritten Spalte sortieren. Dafür muss ich doch nach dem array[2] sortieren oder? Das geht doch ganz gut mit Multisort!? Naja müsste nur mal wissen wie man die einzelnen Spalten auslesen kann, wenn sie durch tab getrennt sind. So sehen die Datensätze aus:

20021018 Fujitsu Siemens 1034864556 1600 1700 Martin Fandel AMT01 FF9900

Gruß

Martin

Falsches Forum....

Verschoben in die Webserverprogrammierung....

Naja so klappt jetzt schonmal das ausgeben der 3. Spalte. Aber warum funktioniert das multisort nicht?

Need help!

Gruß

Martin

###############################ä#

# Spalte bestimmen für Multisort #

#################################

$getzeile = file("../data/getzeile.txt");

for($zeile1 = 0; $zeile1 < count($getzeile); $zeile1++)

{

$termin1 = explode("\t", $getzeile[$zeile1]);

if(trim($termin1[0]) == trim($date1))

{

$termine1[] = $getzeile[$zeile1];

}

}

echo $termin1[2];

########################

# Datensätze sortieren #

########################

array_multisort ($termin1[2], SORT_ASC, SORT_NUMERIC);

echo $getzeile[0];

hab da was gefunden, ist zwar auf mysql Basis gedacht, aber das prinzip ist ja das selbe, vielleicht hilfts:

If you have an array that contains output from a SQL SELECT statment and you want to sort the array on a column, you have to create a separate array containing the values of that column like so:


//Get table output into $rows array
$result = mysql_query("SELECT field1, field2 from table");
while ($rows[] = mysql_fetch_array($result)) {}

//Sort on field2
foreach ($rows as $val) {
$sortarray[] = $val['field2'];
}
array_multisort($rows, $sortarray);

//Now, $rows is sorted on field2

[/PHP]

If anyone knows an easier way to do this, please let us know!

naja ich denke das sollte funktionieren

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.