Skip to content
Advertisement

Print a key in a PHP multidimensional array

I have a multidimensional array and I want to print the contents as follows:

JavaScript

My problem is that I don’t know how to refer to the key of the first sub-array (the names). key($index) just replaces all of the names in the output with “class1”. Here’s my code so far:

JavaScript

I’m pretty new to web development, so if anyone has any hints I’d really appreciate it!

Edit: Am I getting closer…?

JavaScript

Advertisement

Answer

Try with this :

JavaScript

Out put:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement