I have a long list of LCIDs which I want to assign to each other. Here is an extract:
1031
1033
1034
1061
1062
1026
I want to end up having an array or a list which looks like this:
1031 => 1033
1031 => 1034
1031 => 1061
1031 => 1062
1031 => 1026
1033 => 1031
1033 => 1034
1033 => 1061
1033 => 1062
1033 => 1026
1034 => 1031
1034 => 1033
1034 => 1061
1034 => 1062
1034 => 1026
And so on.
Any advice on how to tackle this in PHP? Help is much aprreciated!
EDIT: I now came up with this (still not what I need but I'm getting there somehow...)
foreach($a_languageIDs as $lcid){
$src_lcid = $lcid + 1024;
$trg_lcid = $lcid + 1024;
for ($i = 0; $i < count($a_languageIDs); $i++) {
echo "$src_lcid -> $trg_lcid\r\n";
}
}
Which gives me this output:
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1031 -> 1031
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
1033 -> 1033
This at least gives me this iterated list but I still have no idea how to adapt the value of $trg_lcid.
You can utilize
array_diff
within a loop:How this works:
array_diff
to create an array that holds all the elements except the current one. It works by comparing the first parameter (the full array) against the second one (an array holding only the current element) and returning all the elements of the first parameter that are not present in the second parameter.