Yo, mein bon amigos!
Haven't been here for quite a while. Been concentrating on redesigning a new web site core logic module.
Thought I would stop by and leave some brain droppings. I just made a useful PHP tool that turned out to be very helpful and thought I would share it.
Ever want to see what's inside an associative array, but were afraid to ask?
The raw print_r() function output is rather messy and sticks to your face.
Here's a simple utility function to easily and neatly display an associative array's contents in the form of a table.
Just use the array you want to display as the function input argument.
For example:
Code:
print Array_Query_Table ($_SERVER);
If cookies exist, you can also view their contents the same way, since cookies are stored in a super-global array.
Code:
print Array_Query_Table ($_COOKIE);
The function generates the complete code for a ready-to-print HTML table to display the array contents.
When writing an interactive web page, this function makes it easy to check the contents of the POST and GET or other associative arrays as you debug your program interface.
Try
Code:
print Array_Query_Table ($_POST);
or
Code:
print Array_Query_Table ($_GET);
to see all your I/O form element values.
Here is the function code:
Code:
function Array_Query_Table ($ArrayArg)
{
$out = '';
$x = $ArrayArg;
ForEach ($x as $key => $value)
{
$out .= "<TR><TD BGCOLOR='LightYellow'>$key</TD><TD BGCOLOR='LightCyan'>$value</TD></TR>\n";
}
return "<TABLE BGCOLOR='black' CELLPADDING='2' CELLSPACING='*'><TD BGCOLOR='yellow'>KEY</TD><TD BGCOLOR='cyan'>VALUE</TD>$out</TABLE>";
}
JayT was here
Sponsored by the Swiss Army Condom
You're Ready for Anything In Heaven, Hell or Earth and Beyond the Stars.