<?php // define array $data = array( "UK" =>array( "longname" => "United Kingdom", "currency" => "GBP"), "US" =>array( "longname" => "United States of America", "currency" =>↵ "USD"), "IN" =>array( "longname" => "India", "currency" => "INR")); // print array contents print_r($data); var_dump($data); ?>
The print_r() and var_dump() functions are great ways to X-ray the contents of an array variable, and print a hierarchical listing of its internals. The previous listing
C h a p t e r 4 :Wo r k i n g w i t h A r r a y s 103
demonstrates them both in action. Note that var_dump() produces more verbose output (including information on data types and lengths) than print_r()