
PHP COMPLEX array sorting, reordering and merging
- or -
Post a project like this2867
$$$
- Posted:
- Proposals: 5
- Remote
- #1647386
- Awarded
Description
Experience Level: Expert
Estimated project duration: 1 day or less
General information for the website: Below
Description of requirements/features: We have a an array which contains multiple arrays - each of these arrays has a different number of entries and some of the keys are mixed up.
We need someone to take the current arrays and output to a standardised format array where all the columns line up properly and where "missing" values get added and replaced with NULL.
It is very hard to explain in words so I have attached a copy of the arrays as they are generated and also the CSV output it creates today along with how it should look.
Note in the arrays, some of the keys are mixed up - key 1 is always in the correct place but as soon as any additional keys get added they added in reverse order so rather than having k1, k2, k3, k4 we end up with the keys showing k1,k4,k3,k2 however the data is in the correct order hence the keys need "changing" (see Mortimer McKay in array)
Also this is totally dynamic so any array could have 100's of these key combinations which are generated by using clone fields in a dynamic form. Clone fields always end in $number hence field_a$4 is the fourth clone field of field_a and so on.
The array generation cannot be changed so this needs to be "resolved" at the output level hence the need for this.
Needs to be done in PHP as the output is sent to CSV via an existing PHP script - do not need the CSV part coding so the output of this task should be an array which can then be looped through to get the second CSV in the attached file.
Extra notes:
Description of requirements/features: We have a an array which contains multiple arrays - each of these arrays has a different number of entries and some of the keys are mixed up.
We need someone to take the current arrays and output to a standardised format array where all the columns line up properly and where "missing" values get added and replaced with NULL.
It is very hard to explain in words so I have attached a copy of the arrays as they are generated and also the CSV output it creates today along with how it should look.
Note in the arrays, some of the keys are mixed up - key 1 is always in the correct place but as soon as any additional keys get added they added in reverse order so rather than having k1, k2, k3, k4 we end up with the keys showing k1,k4,k3,k2 however the data is in the correct order hence the keys need "changing" (see Mortimer McKay in array)
Also this is totally dynamic so any array could have 100's of these key combinations which are generated by using clone fields in a dynamic form. Clone fields always end in $number hence field_a$4 is the fourth clone field of field_a and so on.
The array generation cannot be changed so this needs to be "resolved" at the output level hence the need for this.
Needs to be done in PHP as the output is sent to CSV via an existing PHP script - do not need the CSV part coding so the output of this task should be an array which can then be looped through to get the second CSV in the attached file.
Extra notes:

Jason D.
100% (68)Projects Completed
115
Freelancers worked with
99
Projects awarded
33%
Last project
26 Mar 2025
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies