note 119857 rejected from function.array-chunk by cmb
| From: | cmb@php.net | Date: | Wed, 07 Sep 2016 11:28:31 +0000 |
| Subject: | note 119857 rejected from function.array-chunk by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206519@lists.php.net to get a copy of this message | ||
Note Submitter: oleg dot v dot tatarinov at gmail dot com
----
Hi, there is task to do for every web portal, example:
Make 3 columns for the View.
The new function needed, realy.
The code, example:
$i = 0;
foreach($items as $item){
++$i;
if ($i == 3) $i = 0;
$data['items'][$i][] = array(
'name' => $item->name,
'link' => $item->link,
'preview' => $item->preview,
'shortDesc' => $item->shortDesc,
'date' => $item->date,
'content' => $item->content,
);
}
The function can be like this:
array_to_columns($array, $columnsCount, $type)