An application I am working on has me configuring a fairly complex Array (which I might have done wrong in itself)
Here is the array of employees
Code: Select all
<?php
$plantA = array(
"Mike Mann" => array(
"Roles" =>array ("Owner" => "Owner", "CEO" => "CEO"),
"Phone" => "(555) 555-5555",
"Email" => "mike@plantA.com"),
"Sam Newal" => array(
"Roles" =>array ("Owner" => "Owner", "CTO" => "CTO"),
"Phone" => "(555) 555-5554",
"Email" => "sam@plantA.com"),
"Bob Allxon" => array(
"Roles" => array ("Safety Manager" => "Safety Manager",
"Line Manager" => array ("Line1", "Line2", "Line3")),
"Phone" => "(555) 555-5556",
"Email" => "bob@plantA.com"),
"Steve Dunn" => array(
"Roles" => array ("Line Manager" => array ("Line4", "Line5", "Line6")),
"Phone" => "",
"Email" => "steve@plantA.com")
);
?>Code: Select all
<?php
foreach ($plantA as $key => $plantA)
{
print ("$key - ");
foreach ($plantA as $key2 => $info)
{
print ("$info <br> \n");
}
}
?>1) Print out the directory of employees in basic columns of Name Role Phone Email. I got a lot of this licked but I can't figure out how to logically pull all the information from each array.. Mainly how to permeate through the Roles array on each person.
2) Also, on each individual "Line's" page, display that Line's Manager. For example on the page for Line3 it would display the manager as Bob Allxon. I'm not sure how to perform that type of search function on an array to get that result.
Any pointers would be greatly appreciated even it was to redesign the array. Database is not an option for this site besides, like I said I would really appreciate understanding arrays.