I made a schedule, which is a basic and simple table.
I have 2 simple arrays:
Array 1:
$_sp=array();
// 9:15 AM
// KEYNOTE SPEAKER
$_sp[0]=array(
"Name" => "Mr. Smith",
"Title" => "CEO,
"Company" => "Smith's Company",
"Day" => 1,
"Time" => "9:15",
"Room" => 0,
);
...... and there are more like this...
And I have a second Array, selecting time and rooms in use:
The room number is the row (0, 1, 2, 3) and the time is the field (8:30, 9:15, etc)
// ROOMS NOT IN USE ARE COMMENTED OUT with //
$_day1agenda=array();
//INTRO TIME
$_day1agenda[0]=array(
0 =>"8:20");
// SPEAKER 1 TIME (ex: 8:30)
$_day1agenda[1]=array(
0 =>"8:30",
// 1 =>"",
// 2 =>"",
// 3 =>""
);
// SPEAKER2 TIME - Before Break (ex: 9:15)
$_day1agenda[2]=array(
0 =>"9:15",
1 =>"9:15",
// 2 =>"",
// 3 =>""
);
etc etc etc....
To generate the table, I used the foreach statement on the 2nd array ($_day1agenda).
Each cell in the table has a slotted time. When the DAY, the TIME and the ROOM matches from the 1st array ($_sp - the list of speakers), then the speakers name will appear.
It was easy to generate the if statements for the DATE and TIME. The problem I am having is getting both arrays to compare the room #.
In the second array, the room number is the row number.
At 8:30, there can be 2 rooms, in room [0] is speaker A, the other (room [1]) is Speaker B. Without comparing the rooms in the code. BOTH speakers will appear in BOTH of the ROOMS, which is b-a-d. So the rooms must be compared between each array.
My statements were like this:
foreach ($_day1agenda as $_day1agendaIndex => $_day1agendaValue) {
foreach ($_day1agendaValue as $_Time => $_TimeValue) {
foreach ($_sp as $_spkey => $_spValue) {
if ($_sp[$_spkey]['Day']==1) {
echo "Day: ".$_sp[$_spkey]['Day']."<br>\n";
if ($_sp[$_spkey]['Time']==$_TimeValue) {
echo "Time: ".$_sp[$_spkey]['Time']."<br>\n";
// ROOM NUMBER COMPARISON NEEDS TO BE HERE
// THIS DOES NOT WORK
// if ($_sp[$_spkey]['Room']===$_day1agenda[$_day1agendaIndex][$_Time]) {
// PLEASE HELP!!!
// THANKS!!!
echo "Room: ".$_sp[$_spkey]['Room']."<br>\n";
echo "Name: ".$_sp[$_spkey]['Name']."<br>\n";
echo "Title: ".$_sp[$_spkey]['Title']."<br>\n";
echo "Company: ".$_sp[$_spkey]['Company']."<br>\n";
}}}
$sp[$spkey][Room] needs to match up with $day1agenda[$day1agendaIndex][$--THIS--] - Normally, "$--THIS--" in the 2nd array ($_day1agenda) would report in PHP as the the value, or the time (ex: 8:30) - but I need the actual row number ( 0 or 1 or 2 or 3)
What value do I get it to compare the row number in the array and not the resultant field?
Thanks for your help!