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...
blog comments powered by Disqus |
|
|
|
|
|
|
|