Jump to content


Photo

Print or echo multipule arrays


  • Please log in to reply
2 replies to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 03 July 2006 - 08:51 PM

I have a multidirectional array and am wanting to echo or print multiple arrays at one time without having to repeat echo over and over again.

here is an example of my array.php file. I am using a php file because I want to cut down on database queries, for speed reasons

here is an example of my array.php file

               '$home' => array('$home_url', 'Home', 'The Home Of Owpt');
			   '$account' => array(
			                       '$main' => array('$account_url', 'My account', 'My account');
								   '$sub' => array(
								                   '$profile' => array(
												                       'profile', 'Profile', 'Profile'
												                       );												  
												   '$messages' => array(
												                        'account=messages', 'My Messages', 'My Messages'
                                                                       ); 												  
												   '$purchases' => array(
												                        '$account=purchases', 'My Purchases', 'My Purchases'
												                       );
												   '$downloads' => array(
												                        'downloads', 'Downloads', 'Downloads'
                                                                       );
												   '$custom' => array(
												                        '$custom', 'Custom', 'Custom'
                                                                       );
								                  );

			                       );
			   '$support' => array(
			                       '$main' => array('$support_url', 'Support', 'Support');
								   '$sub' => array(
								                   '$live' => array(
												                    'live', 'Live Support', 'Live Support'
												                    );
								                   '$knowledge_base' => array(
												                              'knowledge_base', 'Knowledge Base', 'Knowledge Base'
												                              );
								                   'support_tickets' => array(
												                               '$support_tickets', 'Support Tickets', 'Support Tickets'
												                              );
								                   '$virtual_assitant' => array(
												                                '$virtual_assitant', 'Virtual Assitant', 'Virtual Assitant'
												                               );
								                   '$faq' => array(
												                   'faq', 'FAQ', 'FAQ'
												                  );
			                      );
               ):

I am going to be using switch and I want to print/echo all of, say, the $main s into a format like this.
<li><a href="$link[0]" TITLE="$title[0]">$title[0]</a></li>
<li><a href="$link[1]" TITLE="$title[1]">$title[1]</a></li>
Then I would have a different switch statement for when some one clicks on on one of the links.

I am already using switch and only need to know how to display a set number of the variables. 

I am not wanting to manually echo each one. If that were the case I would just manually input the information

What I would like to do is define how many of the variables will be displayed in that format.

Here is a link to my site so that you may get a better idea of what I am trying to do http://www.owpt.biz/index.php click on one of the links and you will see the navbar move. That is what I am try to achieve.

It is the left navigation bar. It is manually coded right now and works.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 03 July 2006 - 08:55 PM

some how when posting this the arrays got nocked out of postion.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 July 2006 - 10:05 PM

The code you show for your array is not valid.

Please post the valid array. Put the code between [php][/php] tags.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users