How to compare the elements in 2D array in php -
Hello I'm getting an array like this ...
array (array ( 1, 3), array (4, 6, 8), array (2, 3, 5, 1)) Now I compare the first element with all the elements in the second row I want to compare 4,6 and 8 with 1. Then with third row elements, with 1, 2,3,5 and 1. Similarly I want to compare <1 p>
1 is completely present twice given array .... then variable count1 = 2 .... Similarly 3 exists 2 times so many count2 = 2. 8 is present only once, so count8 = 1 .... like this ...
Please help me solve it. thank you in advanced.
If you just after a frequency table, you can level it and get a match You can use:
print_r (array_count_values (call_user_func_array ('array_merge', $ array)); Output:
array ([1] => 2 [3] => 2 [4] = & gt; 1 [ 6] = & gt; 1 [8] => 1 [2] => 1 [5] = & gt; 1)
Comments
Post a Comment