WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - השוואת מחירים בסופר
ZeroLag.com
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Print structured array with offsets
Categories : PHP, Debugging, Arrays Click here to Update Your Picture
Maris Veide
Date : Apr 16th 2004
Grade : 4 of 5 (graded 3 times)
Viewed : 7544
File : 3826.php
Images : No Images for this code example.
Search : More code by Maris Veide
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 



Author Maris Veide
E-mail: [email protected]

Example for printing structured array contents
- Can be very useful for debugging
- Shows visual depth levels using offset symbols - either default or custom


<?php
// Format any array - can be replaced by any kind of array
$array = array();
array_push($array, array("one"=>"This is one", "two"=>"This is two"));
array_push($array, array("a"=>"This is another value", "numbers"=>array(5,4,3,2,1,0)));
$array["somekey"] = "Some value";

echo
"<B>Prints array using default offset symbol:</B><BR>";
print_array($array);
echo
"<HR>";

echo
"<B>Prints array using custom offset symbol:</B><BR>";
print_array($array, "\......");

echo
"<HR>";

echo
"<B>When given parameter is not an array:</B><BR>";
$not_array = "Some text";
print_array($not_array, "\......");


echo
"<HR>";
echo
"(C) Maris Veide, [email protected]";

// --------------------------------------------------------


/************************************************
* Prints structured array contents
*/
function print_array($array, $offset_symbol = "|--", $offset = "")
{
  if (!
is_array($array))
  {
    echo
"[$array] is not an array!<BR>";
    return;
  }
 
 
reset($array);
 
  while (list(
$key, $val) = each($array))
  {
    if (
is_array($val))
    {
      echo
$offset."[$key]=>[$val]<BR>";
     
print_array($val, $offset_symbol, $offset.$offset_symbol);
    } else
    {
      echo
$offset."[$key]=>[$val]<BR>";
    }
  }
}

?>



Function that returns an array with the 7 dates of the week that belong to the supplied date.
Categories : PHP, Date Time, Arrays
Single-file PHP news system with automatic folder structure creation
Categories : PHP, Filesystem, Arrays
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
A time measuring and performance benchmarking class
Categories : PHP, PHP Classes, Testing, Debugging, Date Time
Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays
Takes an array and returns a string, suitable for inputing in an SQL statement
Categories : Arrays, Strings, PHP
Grab images from one or more URLs and save them to a specified local directory.
Categories : PHP, Filesystem, Strings, Arrays
PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
Categories : PHP, Arrays, Variables
PhpView 0.1 - simple php viewer, using temporary files and frames.
Categories : PHP, PHP Options and Info, Debugging, HTML and PHP
Simple PHP Bar Graph using GD library
Categories : PHP, GD image library, Graphics, Arrays
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, Databases
How to Get a character array from a string
Categories : PHP, Strings, Arrays
Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other?
Categories : PHP, Math., Arrays
A function which places the path and name of all subdirectories into an array
Categories : PHP, Filesystem, Arrays, Directories
Human readable PHP password generator
Categories : PHP, Security, Beginner Guides, Arrays