Source of file Csv.php
Size: 1,029 Bytes - Last Modified: 2015-12-22T09:12:14-05:00
../src/View/Helper/Csv.php
12345678910111213141516171819202122232425262728293031323334
Covered by 1 test(s):
35
Covered by 1 test(s):
36
Covered by 1 test(s):
3738
Covered by 1 test(s):
39
Covered by 1 test(s):
40
Covered by 1 test(s):
41
Covered by 1 test(s):
4243
Covered by 1 test(s):
444546
| <?php /** * Csv View Helper * * @category MvcLite * @package Lib * @subpackage View_Helper * @since File available since release 1.1.x * @author Cory Collier <corycollier@corycollier.com> */ namespace MvcLite\View\Helper; use MvcLite\View\HelperAbstract as HelperAbstract; /** * Csv View Helper class * * @category MvcLite * @package Lib * @subpackage View_Helper * @since Class available since release 1.1.x * @author Cory Collier <corycollier@corycollier.com> */ class Csv extends HelperAbstract { /** * The render method for the csv view helper * * @param array $items */ public function render($items = []) { $return = ''; $headers = array_keys((array)$items[0]); $return .= '"' . implode('", "', $headers) . '"'; foreach ($items as $item) { $item = array_values((array)$item); $return .= PHP_EOL . '"' . implode('", "', $item) . '"'; } return $return; } } |