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

 
Developer Updates  
Free Website Content 
 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? 
Google.com  
PHP

PHP: The Switch Statement and Arrays
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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...



     
     
    >>> More PHP Articles          >>> More By James Payne
     

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek