Click to See Complete Forum and Search --> : count()


AnotherMuggle
02-20-2008, 11:20 AM
Can anyone explain to me why I am not able to do this with the count function:

count($this->months)

Thanks,
TK

scragar
02-20-2008, 11:24 AM
I'm guessing $this->months doesn't evaluate as an array, maybe a nodelist or some such.

you could var_dump it to find out what it is, then use a relevant function.

AnotherMuggle
02-20-2008, 11:29 AM
It is an array though:

$this->months = Array("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");

Am I misunderstanding something?

scragar
02-20-2008, 11:36 AM
I don't know why it's not working then, only thing I could think of would be to use a temp variable for testing it like so:
$tmp = $this->months;
echo count($tmp);
unset($tmp);

AnotherMuggle
02-20-2008, 11:37 AM
I don't know why it's not working then, only thing I could think of would be to use a temp variable for testing it like so:
$tmp = $this->months;
echo count($tmp);
unset($tmp);

The output is just 0.

EDIT: Sorry, red herring! I realised I had a typo in my constructor function.

scragar
02-20-2008, 11:42 AM
try var_dump (http://php.net/var_dump)ing it then, that should work...

AnotherMuggle
02-20-2008, 11:50 AM
try var_dump (http://php.net/var_dump)ing it then, that should work...


I have sorted it mate. Was a silly typo :o