tags:

views:

283

answers:

1

Does anyone know how to get arround the annoying problem that when counting how many values there is inside an array if the value is 0 it says 1 becuase it counts the name or something. So like this:

0 : 1
1 : 1
2 : 2
3 : 3
4 : 4
5 : 5
6 : 6
7 : 7
8 : 8

Thnaks, Stanni

+5  A: 

To fully answer the question, I'd need the code for this.

My sneaking suspicion is that whatever you are count()ing isn't an empty array the first time, but something else. An initialized, non-null, non-array and non-Countable-object variable has a count() of 1.

See count's documentation for more info.

Henrik Paul
Haha, thank-you, just placed this code there and it works now ;)if (!is_array($friends2)) {$friends2 = array();}
Ryan