What is the best way to compare 2 arrays and echo out the values of the same content of the array in php?
You could use array_intersect_key
on the menus array and the flipped (to make the values the keys) access array:
$pages = array_intersect_key($menus, array_flip($access['pages_id']));
You could then iterate over the $pages
variable in the same way as you are currently iterating over the $menus
array.