Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to track the number of variables in an array?

Posted on 2011-04-28
Medium Priority
Last Modified: 2012-05-11
If I have an array that is filled with stored $_GET variables how can I know the stored amount?

Would a simple count($_SESSION['cart']) work??
Question by:FairyBusiness
  • 2
LVL 82

Accepted Solution

hielo earned 2000 total points
ID: 35487887
if $_SESSION['cart'] IS an array, then yes,

will tell you how many items are stored in that array.

Author Closing Comment

ID: 35487895
LVL 82

Expert Comment

ID: 35487898
FYI: Using a foreach you can then iterate over its contents:
foreach( $_SESSION['cart'] as $i=>$value )
 echo $i . " " . $value . "<br />";

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question