Given the marcas
table of the teste_db
database (for example)
| id | marca |
| 1 | mercedes|
| 2 | audi |
| 3 | fiat |
| 4 | alfa |
| ...| ... |
|573 | ferrari |
|574 | bentley |
and given an array with n
numerical arguments such as:
$arr = array('3','23','127','574')
and assuming that the array always contains numeric arguments that can be found in the id
column of the table, I would like to include in the array, for each argument of this array, the value marca
whose id
in the table has the same value as the array, and the result would be:
$arr = array("3"=>"fiat", "23"=>"rover", "127"=>"tata", "574"=>"bentley");
What would be the code needed for this task? PHP and mysqli.