I've been getting the following php notice:
Notice: Undefined offset: 9 in include() (line 89 of node--name.tpl.php).
Here's the code:
<?php
// loops through array to print out addendum pdf's.
for ($i = 0; $i < 10; $i++) {
$variable2 = "../sites/default/files/" . $node->field_addendum['und'][$i]['filename'];
$variable1 = $node->field_addendum['und'][$i]['filename'];
if (isset($variable1)) {
$result = $i + 1;
echo "<a href='$variable2' target='_blank'>$result   </a>";}
else {}
}
?>
The field_addendum is a "file" field type from a custom content type. I understand why I'm getting the notice: if the node only has 3 addendums, once the loop gets to $node->field_addendum['und'][3]['filename'] and onwards, there is nothing in the array.
Is there a way to get the number of files without having to loop through the array first?