I have this function I want to accept any associative array and print out the content in tables.
Function UDF_PRINT_DATA($aryMain) {
Echo "<TABLE>";
echo "<tr>";
$fields = count(array_keys($aryMain[0]))
foreach(array_keys($aryMain[0] as $title)){
echo "<th>";
$str = $str . "<td>". $title ."</td>";
echo "</th>";}
echo "</tr>";
echo "<tr>";
for($i=1; $i< $fields; $i++){
if !(is_array($aryMain[$i]){
echo array_values($aryMain as $val). "<br>";
$str.= <td> .$val .</td>;
}else{}
}
echo "</tr>";
Echo "</TABLE>";
}
The problem is it could have sub-arrays in the associative array. I test for that in the if clause but I don't know what to do in the else part. Then you would have to keep testing for arrays in arrays.
thanks,