Erstmal nochmals vielen Dank für die Hilfe!!!!
kleines Testporgamm für Dich, das alle Fragen beantworten sollte
Okay, jetzt versteht ich es ;-) Hab eigentlich den Befehl substr_replace gesucht...
Habe gerade mal meinen Quellcode dahingehend umgeschrieben, dass er nun auch mit Strings arbeitet... die Ausführungszeit ist nun von 18 bis 30 Sek. auf ca. 8 bis 10 Sekunden gesunken, was ne Ersparnis von 200 bis 300% bedeutet... ist schon enorm.
Vielleicht könnte man jetzt hier aber nochwas verbessern:
$nodes = array();
$strSQL = [...];
$clsDB->query($strSQL, true);
while ($row = $clsDB->getResult()) {
$spyMinX = $row['pos_x'] - $row['spy']; if ($spyMinX < $minX) $spyMinX = $minX;
$spyMinY = $row['pos_y'] - $row['spy']; if ($spyMinY < $minY) $spyMinY = $minY;
$spyMaxX = $row['pos_x'] + $row['spy']; if ($spyMaxX > $maxX) $spyMaxX = $maxX;
$spyMaxY = $row['pos_y'] + $row['spy']; if ($spyMaxY > $maxY) $spyMaxY = $maxY;
$strTmp = str_repeat(false, $spyMinY).
$strY = str_repeat(false, $spyMaxY - $spyMinY);
for ($y = 0; $y <= $spyMaxY - $spyMinY; $y++) $strY[$y] = true;
for ($x = $spyMinX; $x <= $spyMaxX; $x++)
$nodes[$x] = $strTmp.substr_replace($nodes[$x], $strY, 0, $spyMaxY - $spyMinY);
}
$clsDB->free();
Vielleicht hast du ja noch eine Idee!? Denn das reine Auslesen der Daten per SQL Abfrage und Durchlauf der Schleife ohne Befehle:
$strSQL = [...];
$clsDB->query($strSQL, true);
while ($row = $clsDB->getResult()) {
$spyMinX = $row['pos_x'] - $row['spy']; if ($spyMinX < $minX) $spyMinX = $minX;
$spyMinY = $row['pos_y'] - $row['spy']; if ($spyMinY < $minY) $spyMinY = $minY;
$spyMaxX = $row['pos_x'] + $row['spy']; if ($spyMaxX > $maxX) $spyMaxX = $maxX;
$spyMaxY = $row['pos_y'] + $row['spy']; if ($spyMaxY > $maxY) $spyMaxY = $maxY;
}
$clsDB->free();
dauert nur ca. 2 bis 3 Sekunden...
Also benötigt der innere Teil:
$strTmp = str_repeat(false, $spyMinY).
$strY = str_repeat(false, $spyMaxY - $spyMinY);
for ($y = 0; $y <= $spyMaxY - $spyMinY; $y++) $strY[$y] = true;
for ($x = $spyMinX; $x <= $spyMaxX; $x++) $nodes[$x] = $strTmp.substr_replace($nodes[$x], $strY, 0, $spyMaxY - $spyMinY);
ca. 5 bis 6 Sekunden... vielleicht kann man da noch etwas optimieren?
Grüße