lundi 28 mai 2018

Parse Array Containing Column Names and Output All Values of Table in Same Order

I have the following array:

Array ( [0] => id [1] => created_on [2] => your_name [3] => your_company [4] => your_county)

What I want to do is parse different tables which may not have all column names matching the array values.

For example:

Table 1:

id  |  your_name  |  your_company
1   |  gabriel    |  xyz_ltd
2   |  christian  |  abc_ltd

Table 2:

id  |  your_name  |  your_country
1   |  andrew     |  UK
4   |  mark       |  France

And would output all the fields with matching column names in same order as the array in one single output.

In this case something like this would be returned if in Comma Delimited:

1,,gabriel,xyz_ltd,
2,,christian,abc_ltd,
1,,andrew,,UK
4,,mark,,France

How can I achieve this?




Aucun commentaire:

Enregistrer un commentaire