I have a multidimensional array. When I try to extract values from the array, the first array, 3 deep (0, bolded) gets skipped everytime. Here's a sampling of the array:
Array
(
[1104566400] => Array
(
[sat] => 1104566400
[strSat] => 01/01/2005
[group] => A
[0] => Array
(
[opOff] => CR2956
[opODay] => 1104220800
[strODay] => Tue
)
[1] => Array
(
[opOff] => DR1464
[opODay] => 1104480000
[strODay] => Fri
)
[2] => Array
(
[opOff] => NT2412
[opODay] => 1104220800
[strODay] => Tue
)
And here's the code to extract the data:
The $writeSch results in the following:
writeSch:
Array
(
[0] => 1104566400^A^DR1464_1104480000^NT2412_1104220800^
)
Notice the first value in the 3rd level, CR2956, is not present. WHY?? Running through the whole array duplicates the problem. Each value in the writeSch array shows the first value in the sch array skipped.
I changed the code to this:
And this is the response:
Array
(
[0] => 1104566400^A^Array^DR1464_1104480000^NT2412_1104220800^
)
Notice now that the first value is listed as an array. Huh?? It is an array, but should be extracted like the other values.
What am I doing wrong? TIA
DreamerZ
Array
(
[1104566400] => Array
(
[sat] => 1104566400
[strSat] => 01/01/2005
[group] => A
[0] => Array
(
[opOff] => CR2956
[opODay] => 1104220800
[strODay] => Tue
)
[1] => Array
(
[opOff] => DR1464
[opODay] => 1104480000
[strODay] => Fri
)
[2] => Array
(
[opOff] => NT2412
[opODay] => 1104220800
[strODay] => Tue
)
And here's the code to extract the data:
Code:
foreach($sch as $key)
{
$tmpSch = "";
$tmpSch .= $key["sat"]."^".$key["group"]."^";
foreach ($key as $data=>$value)
{
if ($data != "sat" && $data != "strSat" && $data != "group")
{
$tmpSch .= $value["opOff"]."_".$value["opODay"]."^";
}
}
$writeSch[] = $tmpSch;
}
echo "writeSch:<pre>"; print_r($writeSch); echo "</pre>";
The $writeSch results in the following:
writeSch:
Array
(
[0] => 1104566400^A^DR1464_1104480000^NT2412_1104220800^
)
Notice the first value in the 3rd level, CR2956, is not present. WHY?? Running through the whole array duplicates the problem. Each value in the writeSch array shows the first value in the sch array skipped.
I changed the code to this:
Code:
foreach($sch as $key)
{
$tmpSch = "";
// $tmpSch .= $key["sat"]."^".$key["group"]."^";
foreach ($key as $data=>$value)
{
if ($data == "sat") { $tmpSch .= $value."^"; }
elseif ($data == "group") { $tmpSch .= $value."^"; }
elseif($data == "strSat") { }
else //if ($data != "sat" && $data != "strSat" && $data != "group")
{
$tmpSch .= $value["opOff"]."_".$value["opODay"]."^";
}
}
$writeSch[] = $tmpSch;
}
echo "writeSch:<pre>"; print_r($writeSch); echo "</pre>";
Array
(
[0] => 1104566400^A^Array^DR1464_1104480000^NT2412_1104220800^
)
Notice now that the first value is listed as an array. Huh?? It is an array, but should be extracted like the other values.
What am I doing wrong? TIA
DreamerZ