17.04.2013, 20:17
Hi,
what is the most efficient way of searching for a string in an array?
For example I have an array holding all vehicle models and if I search for "Box" it should find 3 elements (498 - Boxville, 590 - Freight Box, 609 - Boxville).
Currently I have all my vehicle models and object models in a MySQL database and simply use the following SQL to search for the model:
But I decided to not save static, never changing stuff like vehicle or object models in the database and instead place them directly in the code as an array.
I want create commands which also accept only a part of the vehicle name or object name to be created:
/v inf
/addobject tree
Any ideas?
what is the most efficient way of searching for a string in an array?
For example I have an array holding all vehicle models and if I search for "Box" it should find 3 elements (498 - Boxville, 590 - Freight Box, 609 - Boxville).
Currently I have all my vehicle models and object models in a MySQL database and simply use the following SQL to search for the model:
Код:
SELECT `id` FROM `vehiclemodels` WHERE `name` LIKE = '%Box%';
I want create commands which also accept only a part of the vehicle name or object name to be created:
/v inf
/addobject tree
Any ideas?