Barnaby W. Füi
Elite Member
Now I'm alright with php, this seems to me like it's being way more difficult than it should be. I have the following array:
Array
(
[id] => Array
(
[0] => 19
[1] => 20
[2] => 21
[3] => 22
)
[contractlen] => Array
(
[0] => 52
[1] => 12
[2] => 26
[3] => 20
)
[date] => Array
(
[0] => 1049991102
[1] => 1049999348
[2] => 1050010775
[3] => 1050443311
)
)
The real array is bigger but this is good enough to get the point across.
Each of the 4 entries under each sub-array are linked, i.e. all of the [0]'s belong together. I want to be able to sort them, and keep them all linked together, do it case insensitively, AND be able to do it in a function that works independent of how many arrays there are. array_multisort() is about as close as it gets, but it's not case insensitive (but that can be hacked around if all of the alternatives are worse), and it takes a finite number of arguments (one for each array to be sorted). There is no way to make it dynamic when you gotta pass a different number of arguments depending on what you want to do
. Right now I have this absolutely hideous if-elseif-elseif statement that covers *most* situations (1-16 or something like that), but that's a horrible horrible way to do it, and I'm just having plenty of problems anyways. The fact that I've been staring at this for a couple of days - both of those days being half unconscious from lack of sleep - does not help. 🙁
Array
(
[id] => Array
(
[0] => 19
[1] => 20
[2] => 21
[3] => 22
)
[contractlen] => Array
(
[0] => 52
[1] => 12
[2] => 26
[3] => 20
)
[date] => Array
(
[0] => 1049991102
[1] => 1049999348
[2] => 1050010775
[3] => 1050443311
)
)
The real array is bigger but this is good enough to get the point across.
Each of the 4 entries under each sub-array are linked, i.e. all of the [0]'s belong together. I want to be able to sort them, and keep them all linked together, do it case insensitively, AND be able to do it in a function that works independent of how many arrays there are. array_multisort() is about as close as it gets, but it's not case insensitive (but that can be hacked around if all of the alternatives are worse), and it takes a finite number of arguments (one for each array to be sorted). There is no way to make it dynamic when you gotta pass a different number of arguments depending on what you want to do