/    Sign up×
Community /Pin to ProfileBookmark

How To Output MultiDimentional Array Values ?

Hi,

I grabbed this piece here:
https://www.guru99.com/arrays.html

[code]
$movies =array(
“comedy” => array(“Pink Panther”, “John English”, “See no evil hear no evil”),
“action” => array(“Die Hard”, “Expendables”),
“epic” => array(“The Lord of the rings”),
“Romance” => array(“Romeo and Juliet”)
);
[/code]

Above is multidimentional arrays as you know.
But is the following valid or not ? Multidimentional Associative Array, I trying to build.

Now, how do I echo all the values of the “comedy” array ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@developer_webauthorJul 30.2021 — Hi,

I grabbed this piece here:

https://www.guru99.com/arrays.html

<i>
</i>$movies =array(
"comedy" =&gt; array("Pink Panther", "John English", "See no evil hear no evil"),
"action" =&gt; array("Die Hard", "Expendables"),
"epic" =&gt; array("The Lord of the rings"),
"Romance" =&gt; array("Romeo and Juliet")
);


Above is multidimentional arrays as you know.

But is the following valid or not ? Multidimentional Associative Array, I trying to build.

<i>
</i>$celebrities =array(
"comedians" =&gt; array("first name"=&gt;Pink, "surname"=&gt;panther,"first name"=&gt;Johny, "surname"=&gt;English),
"programmers" =&gt; array("first name"=&gt;Nog, "surname"=&gt;Dog,"first name"=&gt;Mog, "surname"=&gt;Cat),
);


Q1. How do I echo all the keys of the "comedians" array ?

Q2. How do I echo all the values of the "comedians" array ?

Q3. How do I echo all the values of the key "first name" from the programmers array ?
Copy linkTweet thisAlerts:
@developer_webauthorAug 07.2021 — Is not the 2nd code on my previous post valid ?
Copy linkTweet thisAlerts:
@SempervivumAug 07.2021 — Regarding your second code: If the value, e. g. `Pink` is not enclosed by quotes and not preceded by $ it is assumed that it is a constant. However I suspect that this is not what you intended and probably you didn't defined such constants?
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...