13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Multidimensional Arrays<br />

91<br />

Truck Parts<br />

product category<br />

product<br />

Code Description Price<br />

TLR<br />

Code<br />

OIL<br />

Van Parts<br />

Tires<br />

Description<br />

Oil<br />

100<br />

Price<br />

10<br />

TLR<br />

Car Parts<br />

Tires<br />

100<br />

SPK Spark Plugs 4<br />

Code<br />

OIL<br />

Description Price<br />

product Oil attribute 10<br />

CAR_TIR<br />

SPK<br />

Tires<br />

Spark Plugs<br />

100<br />

4<br />

CAR_OIL product Oil attribute 10<br />

CAR_SPK<br />

Spark Plugs<br />

4<br />

product attribute<br />

Figure 3.4<br />

This three-dimensional array allows you to divide products into<br />

categories.<br />

From the code that defines this array, you can see that a three-dimensional array is an<br />

array containing arrays of arrays:<br />

$categories = array( array ( array( ‘CAR_TIR’, ‘Tires’, 100 ),<br />

array( ‘CAR_OIL’, ‘Oil’, 10 ),<br />

array( ‘CAR_SPK’, ‘Spark Plugs’, 4 )<br />

),<br />

array ( array( ‘VAN_TIR’, ‘Tires’, 120 ),<br />

array( ‘VAN_OIL’, ‘Oil’, 12 ),<br />

array( ‘VAN_SPK’, ‘Spark Plugs’, 5 )<br />

),<br />

array ( array( ‘TRK_TIR’, ‘Tires’, 150 ),<br />

array( ‘TRK_OIL’, ‘Oil’, 15 ),<br />

array( ‘TRK_SPK’, ‘Spark Plugs’, 6 )<br />

)<br />

);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!