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
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
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 : 7141
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: mahrs@balta-eko.lv

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, mahrs@balta-eko.lv";

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


/************************************************
* 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 to create a separated list
Categories : PHP, Arrays, Strings
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
Variable serialization and unserialization. Loading and saving variable structures to and from file.
Categories : Arrays, Filesystem, Variables, Strings, PHP
Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI
Categories : Variables, PHP Options and Info, Arrays, URLs, PHP
enhanced date picker with jcript checking for a dynamic date input
Categories : PHP, Java Script, Date Time, Calendar, Arrays
XML To Array
Categories : PHP, PHP Classes, XML, Arrays
Beginners Array Functions
Categories : PHP, Beginner Guides, Arrays
Filling an array with files from any given directory. This example is for the current PHP script's directory.
Categories : PHP, Arrays, Filesystem
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
Finds the median in an array of numbers - Can be used with a MySql database column read into an array
Categories : PHP, Arrays, Databases, MySQL
Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts.
Categories : HTML, Variables, Debugging, PHP, HTTP
translate.php - Assocciative array example, passing a reference to a function.
Categories : PHP, Arrays, Languages, Variables
A recursive function to traverse a multi-dimensional array where the dimensions are not known
Categories : Arrays, PHP, Algorithms
A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array.
Categories : Algorithms, Arrays, PHP, Complete Programs
clearing variables in php3
Categories : Variables, Arrays, PHP