Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Web Architecture : Education - Tutorials
Writing efficient PHP
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
2. Writing efficient code
  


Using multi-dimension arrays with caution page 12 of 15


Try to avoid excessive use of arrays, especially arrays of arrays, unless you really are handling data with two or more dimensions. For example, avoid using $array[0][...] to store one set of data such as the names of the months in a year, and $array[1][...] to store another set of loosely related information, such as sales data for each month. From a performance standpoint, it is more efficient to use two arrays such as $array1[...] (storing the names of the months) and $array2[...] (storing the sales data for each month).


Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact