-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
38 lines (30 loc) · 782 Bytes
/
example.php
File metadata and controls
38 lines (30 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require 'SplitArray.php';
$columns = 4;
$separationSize = 1;
// textarea to array
$textArray = preg_split("/\\r\\n|\\r|\\n/", filter_input(INPUT_POST, 'text'));
$arr = [];
$i = 0;
foreach ($textArray as $val) {
if($val === '') {
$i++;
continue;
}
$arr[$i][] = $val;
}
// convert
$output = SplitArray::div($arr, $columns, $separationSize);
// output
for ($x = 0; $x < count($output); $x++) {
echo '<table border="1" style="float: left;">';
foreach ($output[$x] as $val) {
foreach ($val as $i) {
echo '<tr> <td>' . $i . '</td> </tr>';
}
if ($val !== end($output[$x])) {
echo '<tr> <td> </td> </tr>';
}
}
echo '</table>';
}