I'm trying to use a multi-dimensional array to echo three pieces of information; 'date', 'name' and 'speech'.
I use 'date' (which is a timestamp) as the main index key, and then want to have 'name' and 'speech' stored underneath it. I.e.
$data = array('124674517235' => array('name'=> "John", 'speech'=>"Hello"));
However, I am not sure on how to get the information out using foreach. My output needs to be
'date':'name' - 'speech'
'date':'name' - 'speech'
'date':'name' - 'speech'
and so on.
The code that I came up with was
foreach ($speech_array as $key) {
if ($key <= $lastactive){
unset($speech_array[$key]);
}
if ($key > $lastactive) {
echo date('H:i:s', $key);
echo " : ";
foreach ($key as $name => $val) {
echo $val;
}
echo " - ";
foreach ($key as $speech => $value) {
echo "\"";
echo $value;
echo "\"";
}
echo '<BR>';
}
}
but it gave numerous errors including
Warning: date() expects parameter 2 to be long, string given in /maptest.php on line 128
and
Invalid argument supplied for foreach()
Can anyone show me where I am going wrong?