Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with multidimensional Array... 1

Status
Not open for further replies.

Qmoto

MIS
Oct 21, 2004
74
US
How would I turn something like this...

Code:
public function __construct()
{
  // LINK TYPE
     // ASSOC KEY, FILE NAME, LINK TEXT
$this->KanbanLink_array = array
(
  'KANBAN STATUS' => array
  (
     'CHKRFLST' => array('KanbanStatus.php?p=', 'Check Refill Status'),
     'KBSTLE' => array('KanbanStatus.php?p=', 'Request Kanban Refill'),
     'RKBSTF' => array('KanbanStatus.php?p=', 'Report Kanban Full')
  ),

  'REPORTS' => array
  (
     'BYRRPT' => array('KanbanReport.php?p=', 'Buyer Report'),
     'MMRRPT' => array('KanbanReport.php?p=', 'Mini Mart Report'),
     'SPLYCRPT' => array('KanbanReport.php?p=', 'Supply Cell Report')
  ),
);
}

Into something like this... ?

Code:
Kanban Status
   Check Refill Status
   Request Kanban Refill
   Report Kanban Full

Reports
   Buyer Report
   Mini Mart Report
   Supply Cell Report

Each item on the list would have the href value of:
Code:
<a href="Kanban[Status|Report].php?p=[CHKRFLST|...]">Check Refill Status</a>

Any thoughts?

 
I don't understand.

Are you asking how to restructure the array, or are you asking how to output the data in the array in a specific way?

If it's the first one, the problem will be more complicated than just restructuring the array. Since that array exists in a class definition, class methods which operate on that data will have to be rewritten to reflect the change in the structure of the array.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Sorry, It appears I've neglected to mention that... I'm asking how to ouput the data in a specific way (similar to the second 'code' example I gave)

Thanks for the reply!
 
Maybe:

Code:
<?php
$KanbanLink_array = array
(
	'KANBAN STATUS' => array
	(
		'CHKRFLST' => array('KanbanStatus.php?p=', 'Check Refill Status'),
		'KBSTLE' => array('KanbanStatus.php?p=', 'Request Kanban Refill'),
		'RKBSTF' => array('KanbanStatus.php?p=', 'Report Kanban Full')
	),

	'REPORTS' => array
	(
		'BYRRPT' => array('KanbanReport.php?p=', 'Buyer Report'),
		'MMRRPT' => array('KanbanReport.php?p=', 'Mini Mart Report'),
		'SPLYCRPT' => array('KanbanReport.php?p=', 'Supply Cell Report')
	),
);


foreach ($KanbanLink_array as $kanban_key => $kanban_element)
{
	print $kanban_key;
	print '<br>';
	foreach ($kanban_element as $key => $value)
	{
		print '<a href="' . $value[0] . $key . '">' . $value[1] . '</a>';
		print '<br>';
	}
}

?>

?



Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks sleipnir214!

I feel quite dense for having to ask, and I was soo close so many times, but I was banging my head against a wall yesterday... *sigh*

Thanks again for the help!

(and have a star for the job well done)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top