Головоломка - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Головоломка.php
- <?php
- $collectionDivElements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
- outputBlocks($collectionDivElements);
- function outputBlocks(array $collectionDivElements)
- {
- $iBlock=1;
- for($i=1; $i<=count($collectionDivElements); $i++){
- $element = $collectionDivElements[$i-1];
- if(($i % 2) != 0){
- echo <<<ONE
- <div строка$iBlock>
- <div> элемент $element </div>
- ONE;
- }
- else{
- echo <<<TWO
- \n<div> элемент $element </div>
- </div>\n
- TWO;
- $iBlock++;
- }
- }
- }