Created
February 16, 2017 09:40
-
-
Save faridlab/30b4ee2bec77b7b2a9e6e1494eab2e6b to your computer and use it in GitHub Desktop.
Anu gemes looping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Anu</title> | |
</head> | |
<body> | |
<table> | |
<?php for ($i=0; $i < 5; $i++): ?> | |
<tr> | |
<?php for ($j=($i*5); $j < (($i + 1) * 5); $j++): ?> | |
<td><?php echo ($j + 1); ?></td> | |
<?php endfor; ?> | |
</tr> | |
<?php endfor; ?> | |
</table> | |
</body> | |
</html> | |
---- | |
<?php | |
$data = array(); | |
for ($i=0; $i < 5; $i++): | |
for ($j=($i*5); $j < (($i + 1) * 5); $j++): | |
$data[$i][] = ($j + 1); | |
endfor; | |
if($i % 2 == 1) $data[$i] = array_reverse($data[$i]); | |
endfor; | |
$result = array(); | |
for ($i=0; $i < 5; $i++): | |
for ($j=0; $j < 5; $j++): | |
$result[$i][] = $data[$j][$i]; | |
endfor; | |
endfor; | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Gemes</title> | |
</head> | |
<body> | |
<table> | |
<?php for ($i=0; $i < 5; $i++): ?> | |
<tr> | |
<?php for ($j=0; $j < 5; $j++): ?> | |
<td><?php echo $result[$i][$j]; ?></td> | |
<?php endfor; ?> | |
</tr> | |
<?php endfor; ?> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment