Einzelnen Beitrag anzeigen

omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: PostgreSQL Problem (gepaart mit PHP)

  Alt 27. Feb 2006, 23:58
Hallo Thomas,

versuch es doch mal so...

Code:
  function findId($id, $array) {
    for($i = 0; $i < count($array); $i++) {
      if ($id == $array[$i][0]) {
        return $i;
      }
    }
    return "";
  }
 
  $a = array(array(1, "1. Zeile (A)"),
             array(2, "2. Zeile (A)"),
             array(3, "3. Zeile (A)"));
  $b = array(array(3, "3. Zeile (B)"),
             array(2, "2. Zeile (B)"),
             array(1, "1. Zeile (B)"));
  $c = array();
  for($i = 0; $i < count($a); $i++) {
    $index = findId($a[$i][0], $b);
    if ($index != "") {
      $c[count($c)] = array($a[$i], $b[$index]);
    }
  }
  print_r($c);
$a und $b sind Arrays, die die beiden Inhalte deiner Datenbankabfragen enthalten. Dabei gehe ich mal davon aus, das dein EREIGNIS_TYP jeweils in der ersten Spalte steht.
Beide Arrays werden jetzt in ein neues Array ($c) zusammengeführt.

Hoffe das hilft dir weiter...

MfG
Thorsten
  Mit Zitat antworten Zitat