I am making a script that should sort folders and show them in rows and columns on the web. It should be 4 columns and just continue down until no more folders are found. I got everything except that magic part where it sorts the objects in rows and columns. My idea is that i make two variables: $hor(column) $ver(row) and then i use css to place the objects that the script is making. Does anyone have an idea on how to handle this? Javascript is not an option due to the requirements
This is my script so far:
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
$directory = '/path/to/directory';
$scanned = array_diff( scandir( $directory ), array( '..', '.' ) );
$count = count( $scanned );
echo $count;
for ( $i = 2; $i <= $count + 1; $i++ ) {
$x = $i - 2;
// Magic code that sorts into horizontal and vertical numbers
echo '<div id="' . $x . '" class="' . $hor . ' ' . $ver . '"><a href="/' . $scanned[ $i ] . '"><div class="inner"><p>' . $scanned[ $i ] . '</p></div></a></div>';
}
?>
.hor1{left: a;} .hor2{left: b;} .hor3{left: c;} .hor4{left: d;}and.ver1{top: x;} .ver2{top: y;} .ver3{top: z;}