View Single Post
Old 11-08-2008, 10:52 PM   #1 (permalink)
Mithadriel
The Wanderer
 
Join Date: Nov 2008
Posts: 5
Thanks: 2
Mithadriel is on a distinguished road
Default if within a foreach ?

Hi,

I'm not sure of the best way to do this and thought I might get a bit of help here ... hopefully :)

I have the contents of an array being fed out using a foreach loop, this works just fine and it displays everything as I would like.

What I was hoping to achieve however is that whenever X value appears within the array, I want it to count up on a variable.

So something like:

PHP Code:
foreach ($key as $value) {
      if (
$value == 0) {
          
$variableone ++
      } elseif {
$value == 1) {
               
$variabletwo ++ }

Am I going on completely the wrong track for what I want to do?
Mithadriel is offline  
Reply With Quote