Thursday, May 28, 2009

Count array

Whats the easiest way to count the number of items in an array? I use the
data in the array so its more than just a count.

I simply want to find if the array has more than 5 items then pass a
variable to the view to use a different div.

Example:

[Entry] => Array
(
[0] => Array
(
[id] => 1
[image] => 1243476746.jpg
)

[1] => Array
(
[id] => 2
[image] => 1243476755.jpg
)

[2] => Array
(
[id] => 3
[image] => 1243476767.jpg
)

[3] => Array
(
[id] => 4
[image] => 1243476778.jpg
)

[4] => Array
(
[id] => 5
[image] => 1243476787.jpg
)

[5] => Array
(
[id] => 6
[image] => 1243476804.jpg
)

[6] => Array
(
[id] => 7
[image] => 1243476812.jpg
)

[7] => Array
(
[id] => 8
[image] => 1243476821.jpg
)

[8] => Array
(
[id] => 9
[image] => 1243476834.jpg
)

[9] => Array
(
[id] => 10
[image] => 1243476846.jpg
)

[10] => Array
(
[id] => 21
[image] => 1243546434.jpg
)

)

)



Dave Maharaj
Freelance Designer
dave@widepixels.com
www.widepixels.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: