How to print out menu names in the foreach loop?

How to print out menu names in the foreach loop?

error code: 523