Jump to content

[SOLVED] Array help


GamingWarrior

Recommended Posts

Ok i think i must be doing a stupid mistake.

basically $number is and Array

echo $number (prints "Array")

print_r($number) (prints "Array ( [COUNT(theme_id)] => 4 )")

 

but this is the part the i cant work out

 

echo $number[COUNT(theme_id)] (prints nothing)

 

why would it not print 4 ?

 

Link to comment
https://forums.phpfreaks.com/topic/73939-solved-array-help/
Share on other sites

You are confusing php- it is trying to use the count() function to calculate the key you want. So to solve this problem, use quotes:

echo $number['COUNT(theme_id)'];

 

Using single quotes around array keys is correct coding. Not using single quotes will generate a warning, that can only be seen if you increase the level of your error reporting.

 

Orio.

 

EDIT- I just wanted to add, you should check the "Array do's and don'ts" in the manual for more info.

Link to comment
https://forums.phpfreaks.com/topic/73939-solved-array-help/#findComment-373098
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.