Re: Embedding foreach loops

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

 



John,

I did this, and got my arrays dumped (on one line). After adding line
returns, here is a snippet:

[code=array dump]

array(38) {
["show_01"]=> array(5) {
["title"]=> string(29) "Van Cliburn Gold Medal Winner"
["date"]=> string(16) "Tues. 10/13/2009"
["time"]=> string(4) "11am"
["price"]=> float(4)
["soldout"]=> int(0)
}
["show_02"]=> array(5) {
["title"]=> string(22) "Jack and the Beanstalk"
["date"]=> string(15) "Fri. 10/23/2009"
["time"]=> string(4) "11am"
["price"]=> float(4)
["soldout"]=> int(0)
}

[/code]

and for reference, my original php used to set up arrays

[code=shows.php]

$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;
  $show_02 = array();
  $show_02['title'] = 'Jack and the Beanstalk';
  $show_02['date'] = 'Fri. 10/23/2009';
  $show_02['time'] = '11am';
  $show_02['price'] = 4.00;
  $show_02['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE "0" to "1"
(without quotations).
 $shows['show_02'] = $show_02;

[/code]

Does this dump look right?

On Mon, Aug 10, 2009 at 3:04 PM, John Butler
<govinda.webdnatalk@xxxxxxxxx>wrote:

>  I can't seem to get my foreach loops to work, will PHP parse embedded
>> loops?
>>
>
> yes.
>
> Is this something I need to have in a database to work?
>>
>
> no, you can do it with the arrays...  but it may be easier to work with
> over the long run if that data was in a db.
>
> Anyway right after you finish creating the array and it's embedded arrays,
> in your code, then add this:
> var_dump($shows); //--so you can see what you just created.  If it looks
> right, THEN go on bothering to try and parse it with your (embedded)
> foreach's {
>
> ------------
> John Butler (Govinda)
> govinda.webdnatalk@xxxxxxxxx
>
>
>
>
> --
> 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