netjunky

Untitled

Oct 18th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. public function andYetAnotherTest( $arrayIndex, $columnsMax = 3 )
  2.     {
  3.         $listlen   = count( $this->categories[ $arrayIndex ] );
  4.         $partlen   = floor( $listlen / $columnsMax );
  5.         dis( $partlen );
  6.         $partrem   = $listlen % $columnsMax;
  7.         dis( $partrem );
  8.         $partition = array();
  9.         $mark      = 0;
  10.  
  11.         for ( $px = 0; $px < $columnsMax; $px++ )
  12.         {
  13.             $incr             = ( $px < $partrem ) ? $partlen + 1 : $partlen;
  14.             $partition[ $px ] = array_slice( $this->categories[ $arrayIndex ], $mark, $incr );
  15.             $mark             += $incr;
  16.         }
  17.  
  18.         dis( $partition );
  19.  
  20.         $result = array();
  21.  
  22.         for ( $i = 0; $i < count( $partition[0] ); $i++ )
  23.         {
  24.             $tmp = array();
  25.  
  26.             foreach ( $partition as $column )
  27.             {
  28.                 if ( isset( $column[ $i ] ) )
  29.                 {
  30.                     $tmp[] = $column[ $i ];
  31.                 }
  32.                 else
  33.                 {
  34.                     $tmp[] = '';
  35.                 }
  36.             }
  37.  
  38.             $result[] = $tmp;
  39.         }
  40.  
  41.         dis( $result );
  42.     }
Add Comment
Please, Sign In to add comment