Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function andYetAnotherTest( $arrayIndex, $columnsMax = 3 )
- {
- $listlen = count( $this->categories[ $arrayIndex ] );
- $partlen = floor( $listlen / $columnsMax );
- dis( $partlen );
- $partrem = $listlen % $columnsMax;
- dis( $partrem );
- $partition = array();
- $mark = 0;
- for ( $px = 0; $px < $columnsMax; $px++ )
- {
- $incr = ( $px < $partrem ) ? $partlen + 1 : $partlen;
- $partition[ $px ] = array_slice( $this->categories[ $arrayIndex ], $mark, $incr );
- $mark += $incr;
- }
- dis( $partition );
- $result = array();
- for ( $i = 0; $i < count( $partition[0] ); $i++ )
- {
- $tmp = array();
- foreach ( $partition as $column )
- {
- if ( isset( $column[ $i ] ) )
- {
- $tmp[] = $column[ $i ];
- }
- else
- {
- $tmp[] = '';
- }
- }
- $result[] = $tmp;
- }
- dis( $result );
- }
Add Comment
Please, Sign In to add comment