/    Sign up×
Community /Pin to ProfileBookmark

dimension of an array

I run into a piece of PHP code at the end of this e-mail when trying to learn about array. This code assumes the variable ‘contents’ is a 2-dimensional array once it is verified being an array. Why can’t it other dimension? Thanks!

CODE
——

class pacakage
{
var contents;
…..
function getData()
{

// insert current cart contents in database
if (is_array($this->contents))
{
reset($this->contents);
while (list($products_id, ) = each($this->contents))
{
$qty = $this->contents[$products_id][‘qty’];
…………………….
}
}

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@dotancohenMay 04.2006 — I don't really understand you. Could you please clarify some more?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMay 04.2006 — because each sub-array is a different product(identified by products_id) with probably several array elements (like qty : quantity)
×

Success!

Help @wmw 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...