Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKnowledgeWoods Consulting
5,607 PointsCount function not working
Please help
5 Answers
Matt Campbell
9,767 PointsNeed a bit more information. What code are you writing? What is it doing or what is it not doing?
KnowledgeWoods Consulting
5,607 PointsPlease provide the correct code so that i can check
Matt Campbell
9,767 PointsI don't know what you're wanting to do. If it's in a foreach loop, then each time the loop runs, you need to add 1 to your count variable.
KnowledgeWoods Consulting
5,607 PointsHow we add that?
Matt Campbell
9,767 Pointshttp://stackoverflow.com/questions/6220546/count-number-of-iterations-in-a-foreach-loop
Google is your friend!
That's just counting how many things are spat out of the foreach loop. You can move onto using print_f and add the count as ids and stuff.