내 코드에 어떤 문제가 있습니까 ??? ??? : 내가 생각기능이 포함되어 있지 않은 이유는 무엇입니까?
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;
, 나는 "TD-태그"로 my_function()을 포함하지만, 때문에 아무도 반향 내 변수 ($ 경로 $ DefaultPath 이렇게)의 작업을 나던. 내 실수를 찾을 수 없습니까? 나를 도와 줄 수 있습니까? ... 인사말
문자열을'echo'하지 말고,'return'합니다. –