• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

How to track the number of variables in an array?

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??
0
FairyBusiness
Asked:
FairyBusiness
  • 2
1 Solution
 
hieloCommented:
if $_SESSION['cart'] IS an array, then yes,
count($_SESSION['cart'])

will tell you how many items are stored in that array.
0
 
FairyBusinessAuthor Commented:
Cool
0
 
hieloCommented:
FYI: Using a foreach you can then iterate over its contents:
foreach( $_SESSION['cart'] as $i=>$value )
{
 echo $i . " " . $value . "<br />";
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now