Hallo zusammen,
Ich verliere die Werte nachdem ich die funktion (FfillGroup) cancele mit return obwohl ich eine globale variable ($Array3d) benutze (ohne globale genau die gleiche ... ) solange ich die funktion rekursiv aufrufe sind die werte da.
der code hier ist halt ohne login pw infos zur datenbank aber der table sieht so aus:
hier noch ein mail das ich an nen kumpel in genau der sache geschickt habe ich hoffe es bringt was:
-----------------------------------------------------------------------
Codezeile 143 würd ich sagen.
Eigentlich läuft alles gut der Array sieht am ende in der function nach dem rekursiv call so aus:
5 9 8 7 6
4
1
10
In der globalen Variable.
Doch sobald ich im aufruflevel zurück bin sind die werte weg. Doch die Werte welche ich fix reinschreibe also BspArray[10][0][0] = 120 bleiben da.
Das prinzip ist:
Erst wird oberstes rootelement definiert ist 16 also:
16
Dann erste reihe mit alles 16er als root
16
5
4
1
10
Danach alle mit 5 als root.
16
5 9 8 7 6
4
1
10
Usw.
Nur die werte bleiben nicht. (bis zum return aber imho schon)
---------------------------------------------------------------------------
danke für hilfe im voraus.
gruss
(ge)stress(t)
id doc_id group_id rootgroup_id
5 1 5 16
4 1 4 16
1 1 1 16
9 1 9 5
8 1 8 5
7 1 7 5
6 1 6 5
18 1 11 3
16 1 15 3
15 1 13 3
14 1 12 3
16 1 15 2
13 1 13 2
12 1 12 2
11 1 11 2
3 1 3 1
2 1 2 1
17 1 16 0
10 1 10 16
19 1 14 4
hier der code:
<html>
<head>
<title></title>
</head>
<body>
	
<br>
</body>
</html>
					Ich verliere die Werte nachdem ich die funktion (FfillGroup) cancele mit return obwohl ich eine globale variable ($Array3d) benutze (ohne globale genau die gleiche ... ) solange ich die funktion rekursiv aufrufe sind die werte da.
der code hier ist halt ohne login pw infos zur datenbank aber der table sieht so aus:
hier noch ein mail das ich an nen kumpel in genau der sache geschickt habe ich hoffe es bringt was:
-----------------------------------------------------------------------
Codezeile 143 würd ich sagen.
Eigentlich läuft alles gut der Array sieht am ende in der function nach dem rekursiv call so aus:
5 9 8 7 6
4
1
10
In der globalen Variable.
Doch sobald ich im aufruflevel zurück bin sind die werte weg. Doch die Werte welche ich fix reinschreibe also BspArray[10][0][0] = 120 bleiben da.
Das prinzip ist:
Erst wird oberstes rootelement definiert ist 16 also:
16
Dann erste reihe mit alles 16er als root
16
5
4
1
10
Danach alle mit 5 als root.
16
5 9 8 7 6
4
1
10
Usw.
Nur die werte bleiben nicht. (bis zum return aber imho schon)
---------------------------------------------------------------------------
danke für hilfe im voraus.
gruss
(ge)stress(t)
id doc_id group_id rootgroup_id
5 1 5 16
4 1 4 16
1 1 1 16
9 1 9 5
8 1 8 5
7 1 7 5
6 1 6 5
18 1 11 3
16 1 15 3
15 1 13 3
14 1 12 3
16 1 15 2
13 1 13 2
12 1 12 2
11 1 11 2
3 1 3 1
2 1 2 1
17 1 16 0
10 1 10 16
19 1 14 4
hier der code:
<html>
<head>
<title></title>
</head>
<body>
PHP-Code:
	
	
<?php
function initarray()
{
        $y = 0;
        $x = 0;
        $z = 0;
        global $test;
        $test = array();
        for($y=0; $y<5; $y++) {
                $test[$y][$x][$z] = 0;
                for($x=0; $x<5; $x++) {
                        $test[$y][$x][$z] = 0;
                        for($z=0; $z<5; $z++) {
                                $test[$y][$x][$z] = 0;
                        }
                }
        }
        return $test;
}
function FfillGroup($sendY, $sendX, $sendZ, $counter, $rootgroup, $firstflag, $Array3d)
{
//        $dArray = Array(Array(Array(50)));
        $dblink = mysql_connect("xxxxxxxxx","xxxxxxxx","xxxxxxx") or die ("No connection");
        print "dbaccess success";
        mysql_select_db("plenu1") or die ("bla");
        $sql = "SELECT * FROM docgroupmap where doc_id = 1 ORDER BY rootgroup_id";
        $query = mysql_query($sql, $dblink);
        $y = $sendY;
        $x = $sendX;
        $z = 0;
        if ($counter == 0) {
                 
             global $Array3d;     
            $test = initarray();
            $Array3d = $test;
            echo "test";
            $Array3d[0][0][0] = 0;
            $rootgroup = 16;
            
            $Array3d[5][5][0] = 1203;
            
            $Array3d[20][0][0] = 112;
            $sendY = 1;
        }
        else {
                while ($result = mysql_fetch_array($query)) {
                        if ($result["rootgroup_id"] == $rootgroup) {
                                switch ($counter) {
                                case 1:
                                        if ($firstflag == 0) {
                                                $sendY = $y;
                                                $sendX = 1;
                                                $firstflag = 1;
                                        }
                                                $Array3d[$y][$x][$z] = $result["group_id"];
                                                echo "dasY" . $y;
                                                echo $x;
                                                echo $z;
                                                echo $Array3d[$y][$x][$z];
                                                ($y++);
                                        break;
                                case 2:
                                        
                                        if ($firstflag == 0) {
                                                $sendY = $y + 1;
                                                $sendX = $x;
                                                $firstflag = 1;
                                        }
                                                $Array3d[$y][$x][$z] = $result["group_id"];
                                                echo $Array3d[$y][$x][$z];
                                                ($x++);
                            
                                        break;
                                }
                      }
                }
                    
            $rootgroup = $Array3d[$sendY][$x][$z];   
         }
      
        echo $Array3d[0][0][0];
        echo $Array3d[1][0][0];
        echo $Array3d[2][0][0];        
        echo $Array3d[3][0][0];
        echo $Array3d[4][0][0];
//        mysql_free_result($query);
        ($counter++);
//        echo $counter;
        if ($counter < 3) {
           FfillGroup($sendY, $sendX, $z, $counter, $rootgroup, 0, $Array3d);
        }
        else {
            return $Array3d;
        }
}
        FfillGroup(0,0,0,0,0,0,0);
//      echo $dArray[1][0][0];
        echo $Array3d[0][0][0];
        echo $Array3d[1][0][0];
        echo $Array3d[2][0][0];
        echo $Array3d[20][0][0];
/*        echo $dArray[3][0][0];
        echo $dArray[4][0][0];
        echo $dArray[5][0][0];
        echo $dArray[6][0][0];
*/                    
        print_r($Array3d);
?>
</body>
</html>
 
          
 Moderator
 Moderator
 
							
						
Kommentar