PHP
  Home arrow PHP arrow Page 6 - PHP: The Switch Statement and Arrays
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

PHP: The Switch Statement and Arrays
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2008-01-07

    Table of Contents:
  • PHP: The Switch Statement and Arrays
  • The Variable's Big Brother
  • Printing the Array Values
  • Associative Arrays
  • The Multidimensional Array
  • Beyond Multidimensional Arrays

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    PHP: The Switch Statement and Arrays - Beyond Multidimensional Arrays
    (Page 6 of 6 )

    You can also create arrays that are two-dimensional, three-dimensional, and so on. You could even have a fifth-dimensional array. If you don't want to kill yourself though, or some unfortunate programmer who has to come along and read your code in the future, then you may just want to max your arrays to the third-dimension.

    Here is a sample of a quick two-dimensional array:


    <html>

    <body>

    <?php


    $soda = array( array(Type=>“Mountain Dew”,

    Price=> 1.25,

    Quantity=> 20)

    ),

    array(Type=> “Pepsi”,

    Price=> 1.25,

    Quantity=> 22,

    ),

    array(Type=>“Mello Yello”,

    Price=>1.25,

    Quantity=> 30

    )

    );

    ?>

    In the above example we use Associative arrays inside our two-dimensional array to create the column names. Otherwise we would have to use numbers, and things would get really ugly.

    Well, that's it for this tutorial. In the (eventual) next episode we will go over Loops inside of PHP. So come back often.

    Till then...


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · There is a mistake in codeinstead of $mygirlfriends[1] . “and” . $names[2]...
       · Hey thanks for catching that. They tie me up in a dungeon and force me to write...
     

       

    PHP ARTICLES

    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway