php - push into every element of an multidimentional array -
Sorry for being a novice I have a multi-dimensional array
array (3) {[0] = array (2) {[type] = & gt; Car, [model] = & gt; Mazda} [1] = array (2) {[type] = & gt; Car, [model] = & gt; Lexus} [3] = array (2) {[type] => Car, [model] = & gt; Lexus}}
Now I want to loop through this array in every way and with the result i.e. The car company wants to get links from the database and push it into this current array. The end result should be shown
array (3) {[0] = array (3) {[type] => Car, [model] = & gt; Majaa, [link] = & gt; Http://mazda.com} [1] = array (3) {[type] => Car, [model] = & gt; Lexus [link] = & gt; Http://lexus.com} [3] = array (3) {[type] = & gt; Car, [model] = & gt; Rangerover [link] = & gt; Http://rangerover.com}}
I can easily loop through this array and get results but I do not know that this new result is this array How to push in
Please help !!!
If you have a website in the database, then it may be possible to collect all the data using JOIN The best idea is to:
(pseudo code) Select c.id = w.car_id For ($ i = 0; $ i & lt; Count ($ origArray); $ I ++) {$ originArray [i] ['link'] = $ dbArray ['karname']; // or whatever the relationship - name, id, etc ...
Assume that $ dbArray looks like this:
'mazda' = & Gt; 'Http://mazda.com', 'Rangerover' = & gt; 'Http://rangerover.com', etc ...
Comments
Post a Comment