PHP array_merge combining arrays with same values -


I have two arrays which I am adding to one and I have several that may possibly be duplicates. Looked and it makes great sense. This is an example that I am trying to achieve.

  array1 ('make and model 1', 'make and model 2', 'make and model 1' ...); Array 2 ('serial number 1', 'serial number 2', 'serial number 3' ...); Array 3 ('Other make and model 1', 'Other make and model 2', 'other AK and model 3' ...); Array 4 ('Other Serial Number 1', 'Other Serial Number 2', 'Other Serial Number 3' ...); $ Make = array_merge ($ array1, $ array3); $ Serial = array_merge ($ array2, $ array4); Foreach ($ make, $ serial) $ model = & gt; $ Number): if (($ model == "") || $ model == "other"): ... code ... endiff; Endforeach;  

Now you can see that I have two make and model 1, what is happening is that it is in combination with arrays, but with the first make and model 1 Instead of showing what I am trying to do with a lower item than my client's clients. What is the way to fix this?

There may be repeated values ​​in the array, but for obvious reasons, the repeated key array_combine Overlays the value according to each duplicate key.

To make the key of your array_combine serial number, assuming that all your serial numbers are unique, a simple solution:

  foreach ( Array_combine ($ serial, $ formatted) $ number = & gt; $ as model):  

If you have between one and a few between "Make" and "Serial Number" If you have relationships, you may want to consider changing your data structure so that each serial number can match an array.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -