for ($i=40; $i>=30; $i--) //code will display data for top x row
for ($i=1; $i<=9; $i++) //code will display data for left y column
for ($i=29; $i>=21; $i--) //code will display data for bottom x row
for ($i=30; $i>=39; $i++) //code will display data for right y column
이러한 4 개의 루프는 모두 동일한 작업을 수행합니다. 내 index.php에서 "포함"을 사용하여 4 개의 다른 파일에있는 4 개의 루프를 가져옵니다. for 루프를 어떻게 동적으로 만들 수 있습니까?어떻게 for 루프 매개 변수를 동적으로 만들 수 있습니까?
Algoritihm :
$i = (40,1,29,30) <--will be any of those 4
$maxlow = (30,9,21,39)
$check =(>,<) <--value depends on whether $i > or < $maxlow
$icrement = (--,++) <-- if $check is > then decrease, otherwise increment
for ($i; $i($check)=$maxlow; $i($increment) <---what i am trying to do
Hey Roman for for 루프가 실행 됨 myfunction()에서 $ diff, $ start, $ stop 변수를 매개 변수로 전달하려면 어떻게해야합니까? 또는 myfunction()에 사용할 수있는 가장 좋은 방법은 무엇입니까? –
함수 myfunction ($ diff, $ start, $ stop)을 선언하고 같은 방법으로 호출하면 –
하하 그래, 고맙다. 그러나 여전히 답을 고맙게 생각합니다. –