First time posting on stackoverflow.
After printing the main array, I managed to highlight the values found in the second, but I also want to print the number of times when the duplicate occurs in brackets at the same time. I have run out of ideas on how to do this last part, I am stuck in several cycles and other problems. I will put here what works now.
Code:
$main = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ); $secondary = array( 1, 6, 10, 6, 17, 6, 17, 20 ); foreach ( $main as $number ) { if ( in_array( $number, $secondary ) ) { echo $item;
EXPECTED RESULT:
1 (1), 2, 3, 4, 5, 6 (3), 7, 8, 9, 10 (1), 11, 12, 13, 14, 15, 16, 17 (2), 18, 19, 20 (1)
Basically, the brackets contain the number of times this value is found in the second array, except for the color, but for some reason I can’t insert the html code. Sorry for not making the expected result more understandable!
SOLVING THE PROBLEM: Thank you all for your help, using this site for the first time, I did not expect such a quick response from you guys. Thank you very much!