Re: Embedding foreach loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> $shows = array();
>  $show_01 = array();
>  $show_01['title'] = 'Van Cliburn Gold Medal Winner';
>  $show_01['date'] = 'Tues. 10/13/2009';
>  $show_01['time'] = '11am';
>  $show_01['price'] = 4.00;
>  $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
> (without quotations).
>  $shows['show_01'] = $show_01;
[etc.]

If I'm setting up a lot of static data ahead of time like this, I
prefer a slightly simpler syntax (or at least it seems simpler to me):

$shows = array(
    'show_01' => array(
        'title' => 'Van Cliburn Gold Medal Winner',
        'date' => [etc.]
    ),
    'show_02' => array(
        'title' => [etc.]
    ),
    [etc.]
);

And sure, you could do all this in a database, or some other sort of
external storage, but unless you're looking at creating a separate UI
for someone other than yourself to input the data, it's probably
simpler all around just to define the data directly in PHP. No reason
you couldn't upgrade to something more sophisticated down the road, if
the customer requires it.

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux