The effects of fluid inertia on the pressure drop required to drive fluid flow through periodic and random arrays of aligned cylinders is investigated. Numerical simulations using a lattice-Boltzmann formulation are performed for Reynolds numbers up to about 180. The magnitude of the drag per unit length on cylinders in a square array at moderate Reynolds number is strongly dependent on the orientation of the drag (or pressure gradient) with respect to the axes of the array; this contrasts with Stokes flow through a square array, which is characterized by an isotropic permeability. Transitions to time-oscillatory and chaotically varying flows are observed at critical Reynolds numbers that depend on the orientation of the pressure gradient and the volume fraction. In the limit Re much less than 1, the mean drag per unit length, F, in both periodic and random arrays, is given by F/(mu U) = k(1) + k(2) Re-2, where mu is the fluid viscosity, U is the mean velocity in the bed, and k(1) and k(2) are functions of the solid volume fraction phi. Theoretical analyses based on point-particle and lubrication approximations are used to determine these coefficients in the limits of small and large concentration, respectively. In random arrays, the drag makes a transition from a quadratic to a linear Re-dependence at Reynolds numbers of between 2 and 5. Thus, the empirical Ergun formula, F/(mu U) = c(1) + c(2) Re, is applicable for Re > 5. We determine the constants c(1) and c(2) over a wide range of phi. The relative importance of inertia becomes smaller as the volume fraction approaches close packing, because the largest contribution to the dissipation in this limit comes from the viscous lubrication flow in the small gaps between the cylinders.