zabbix
Results 1 to 10 of 10

Thread: Array of Hope

Threaded View

  1. #1
    Join Date
    Aug 2007
    Posts
    122

    Array of Hope

    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.
    Last edited by JayT; 03-22-2008 at 09:20 PM.
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

Similar Threads

  1. i hope to see it
    By saudi good good in forum General discussion
    Replies: 18
    Last Post: 02-25-2009, 03:23 PM
  2. Input text file to array help
    By Deadvacahead in forum Programming
    Replies: 0
    Last Post: 12-06-2007, 07:56 PM
  3. Array Of Hope
    By JayT in forum Programming
    Replies: 3
    Last Post: 09-27-2007, 09:49 PM
  4. i hope this is the appropriate place to post this
    By joefro4568 in forum Programming
    Replies: 0
    Last Post: 08-18-2007, 08:01 AM
  5. i hope you can help me
    By ferdelgadillo13 in forum Internet Privacy
    Replies: 3
    Last Post: 01-17-2007, 02:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts