die Funktion wird nicht im vorgegebenen Bereich ausgeführt:
	
	
	
		
was ist den nun hier falsch in der Funktion'? Es wird werder der eine "path" noch der andere "defaultPath" ausgegeben...lg
				
			
		PHP:
	
	  function my_function()
  {
    $states = array('schwarz', 'rot', 'blau');
    $path = '';
    foreach ($states as $state) {
        $testPath = sprintf('transactions/Ordner/%s.png', $state);
        if (file_exists($testPath)) {
          $path = $testPath;
          echo $path;
        }
        else {
          $defaultPath = "inventory_images/8.jpg";
          echo $defaultPath;
        }
    }
  }
  $imagesPerLine = array(1=>2, 2=>3); $default = 4;
  $lines = array(1, 2, 3);
  $html="";
  foreach ($lines as $line) {
    if (!isset($imagesPerLine[$line])) {
      $imagesPerLine[$line] = $default;
    }
    $html.= "<tr>\n";
    for ($i = 1; $i <= $imagesPerLine[$line]; $i++) {
      $html.=sprintf("<td>%s</td>\n", my_function());
    }
    $html.="</tr>\n";
  }
  echo $html;
	
			
				Zuletzt bearbeitet: