przewiń do treści

Symfony 2 od podstaw

Włodzimierz Gajda

class DefaultController extends Controller
{
    /**
     * @Route("/")
     * @Template()
     */
    public function indexAction()
    {
        $t = array();
        foreach (file('../data/dziela_literatury_swiatowej.txt') as $l) {
            $e = explode('|', trim($l));
            $t[] = array(
                'autor'      => $e[0],
                'tytul'      => $e[1],
                'literatura' => $e[2],
                'data'       => $e[3],
            );
        }
        return array('literatura' => $t);
    }
}

Listing 11.13. Zmodyfikowany plik DefaultController.php

Rozdział 11. Instrukcje sterujące for oraz if

listing-11-13.txt

Reklama

Szkolenia z Symfony 2.1
©2012 Włodzimierz Gajda
ver. 1.0.1