0
I have these arrays as reference:
$a_controle = array ('A','B','C','D','E','F');
var_dump($array_final) =>
array (size=5)
0 =>
array (size=3)
0 => string 'A' (length=1)
1 => string 'B' (length=1)
2 => string 'C' (length=1)
1 =>
array (size=3)
0 => string 'A' (length=1)
1 => string 'B' (length=1)
2 => string 'D' (length=1)
2 =>
array (size=3)
0 => string 'A' (length=1)
1 => string 'C' (length=1)
2 => string 'E' (length=1)
3 =>
array (size=3)
0 => string 'D' (length=1)
1 => string 'E' (length=1)
2 => string 'F' (length=1)
4 =>
array (size=3)
0 => string 'A' (length=1)
1 => string 'B' (length=1)
2 => string 'P' (length=1)
How can I count how many times each element of $a_controle
left along with another in $array_final
?
For example:
- The To appeared with B 3 times
- The To appeared with C 2 times
- The To appeared with D 1 times
- The To appeared with And 1 time
- The To appeared with F 0 times
The verification of To passes to the next element of $a_controle
(element B):
- The B appeared with C 1 time
- The B appeared with D 1 time
- The B appeared with And 0 time
- The B appeared with F 0 time
The verification of B passes to the next element of $a_controle
(element C).
The verification of C passes to the next element of $a_controle
(element D).
The verification of D passes to the next element of $a_controle
(element AND).
The verification of And passes to the next element of $a_controle
(element F).
So successively for an array of unknown size. It is possible?
But I didn’t understand this way out. Why is the letter D like 2? Would A come out with D 2 times? Because if it is incorrect.
– jsnow
@jsnow The letter
D
is as 2 because it came out 2 times. It is in the sub-root[1] as the last element and in the sub-root[3] as the first element. Writing otherwise$array_final[1][2]
hasD
and$array_final[3][0]
also hasD
– Isac
I don’t think you understand. I wonder how many times EACH element came out with ANOTHER using the
$a_controle
. The way I explained it upstairs. I need you to check the A with B, C, D, E, F. Then B with C, D, E, F. Then C with D, E, F and so on for each letter.– jsnow
@jsnow I have also edited the answer, which I think I have now got what I wanted, so I would ask you to confirm
– Isac
perfect, exactly what I intended. I will study your code to better understand what is happening there. Thank you!
– jsnow