Forum Moderators: coopster

Message Too Old, No Replies

Wild cards for array keys?

         

benj0323

2:58 am on Oct 23, 2004 (gmt 0)

10+ Year Member



I have a pretty complex array that stores information for fields. The following array element is a boolean:

$_POST['fields'][$i]['listing']

Where $i starts a 1 and can go on for however long the user inputs into the form. So lets say the users input 20 fields. How exactly would I count how many of those array elements are equal to 1, without doing a loop? Is it possible to insert a wild card in place of $i? I already have a lot of nesetd loops and the last thing I want to do is add another one. Thanks.

Robber

9:48 am on Oct 23, 2004 (gmt 0)

10+ Year Member



When you're adding your fields to the array could you add an if to test if $i === 1, if it does increment a counter variable, lets say $j.