F
F
Fyodor2014-09-03 08:58:30
PHP
Fyodor, 2014-09-03 08:58:30

What is the best way to work with array data?

The array is large enough, multidimensional, like
Data[0]['aaData'][0] - resort id
Data[0]['aaData'][1] - number of nights
Data[0]['aaData'][2] - departure date
Data[1]['aaData'][0]
Data[1]['aaData'][1]
Data[1]['aaData'][2]
etc. Of course there are more fields, the most significant ones are indicated.
Actually, I’m thinking, according to my mind, how can I do the following - split the data into resorts by id, inside the resort already get a breakdown into data on the number of nights and departure dates (different departure dates with the same number of nights can be). I didn’t work much with arrays, schemes come to mind about sorting through multiple arrays with obtaining the necessary data (whatever there is), then enter them into the conditions and make more passes and already show, but I think this is the wrong method. maybe it's easier to create a temp table in mysql?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-09-03
Protko @Fesor

do you want to optimize fetches from arrays? Invent indexes for arrays? (you can implement an indexing mechanism with binary search or using hashmaps for primary keys).
If this array is taken from the database, then the selection should be made in it.
otherwise, writing the array to the database and selecting it there will be slower than a blunt search in the forehead. Only if the data is already there and will you reuse this table will there be a profit.

A
Anton Solomonov, 2014-09-03
@Wendor

$data[$id_курорта]['night_count'] = 1; // количество ночей
$data[$id_курорта]['air_date'] = "2014-09-03"; // даты вылета

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question