I'm trying to build a tool to average values from a multidimensional array in PHP. Array sample:
$t[1][1]=2;
$t[1][2]=3;
$t[2][1]=5;
$t[3]=6;
$t[4][1][1]=9;
$t[4][1][2]=10;
$t[4][2][1]=12;
$t[4][2][2]=13;
Notice, too, that parents have no value (Since they have children). I have this:
function chklevel($s) {
$l = explode(".",$s);
}
Which gives me the ability to call chklevel as
chklevel("4.2.2")
and have it return 13, but I also want to be able to call
chklevel("4")
and have it return 11 (Which is the average of 4.1.1(9), 4.1.2(10), 4.2.1(12) and 4.2.2(13).
Any thoughts?
chklevel(4.2.2)
when the parameter is not a string? This will throw an error. Also, the function chklevel doesn't return anything yet, is that intentional? Maybe I just don't get your question good enough. – Czechnology Mar 5 '11 at 21:16