how to retrieve the index size of a field array What I am working with it this. I have a custom content type with an image field (field_img) that accepts multiple images so they are stored in an array. what I need to figure out how to do is one of two things and I need to do them from the node--custom.tpl.php if possible.

1: get the size of the $node->field_img array so I can then loop through and assign appropriate HTML id's for each image in the content type.

OR

2: directly loop through the field_img array using maybe foreach() to set the id of each image in the content type to an appropriately unique value.

what I am able to do here works for one value because I can put in the actual index of the instance I am working with but the arrays are not all the same length some have 10 images some have only 6 so I need something that will loop through the array.

Here is the static code that works for one element

&lt;div id="gallery-img-wrapper"&gt;  

&lt;?php $i = 0 ?&gt;

&lt;img class="album-image&lt;?php print $i ?&gt;" src="&lt;?php print render (file_create_url($node-&gt;field_img['und'][$i]['uri'])); ?&gt;"&gt;

&lt;/div&gt;


this is inside node--gallery.tpl.php and it works fine but it only displays 1 image and I need 14 or how ever many there are for the instance of the content type.
You mention foreach(), but did you try it? Seems to me that it should work. foreach($node-&gt;field_img[LANGUAGE_NONE] as $key =&gt; $value)