![]() |
Searching through multidimensional arrays
Hi,
I need advice about searching through multidimensional arrays. My array contains product data for a webshop. This is the structure: PHP Code:
Is there a way to do this without having nested foreach loops? Tell me If I am not clear enough. Any help is greatly appreciated! /Swiftaxe |
Quote:
|
Thanks! I thought doing several sql-queries would be more time-consuming.
So making a dozen of these queries would be faster?: "SELECT title FROM products WHERE id=$id LIMIT 1" |
Village Idiot,
I timed the two different approaches. Doing 16 sql queries was way slower than looping the arrays. Sql query time: 0.002832 msec Array looping time: 0.000097 msec But I guess that if there were thousands of products the sql would be faster. I only have about 30 in my test. |
Quote:
|
| All times are GMT. The time now is 01:58 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0