views:

68

answers:

2

I have a script i am writing. it parses through a list of scanned (barcoded) items and pulls data about the items. It also needs to count how many times each item was scanned. The part number is called $partselect. Ideally, I would like to store them in an array called $count with the format of $count[$part] = (number of times it's been scanned.) Later, I'd like to be able to display a table showing each entry in $count and the number associated with it.

Currently I am, if the part number is A1234, creating a variable called $countA1234 using the syntax: $count{$partselect}

I've tried various combinations of brackets and single/double quotes but cant figure out how to make that an array instead. I thought $count[{$partselect}] would do it, but no dice.

Related question is at: http://stackoverflow.com/questions/3505548/

A: 

Are you possibly looking for foreach?

When you need the information back out again just use

foreach($count as $part => $numItems)
{
     //Do stuff
}
Kristoffer S Hansen
A: 

Check out the docs about Php arrays

Iznogood