Link to home
Start Free TrialLog in
Avatar of Eternal_Student
Eternal_StudentFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP foreach loop question

Hi,

I want to increment the class name in the attached code by +1 each time it is outputted, so I end up with something like this:

catItemExtraFieldsValue1
catItemExtraFieldsValue2
catItemExtraFieldsValue3

Thanks
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
				<span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
			<?php endforeach; ?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think angelIII has answered your question, but I've got the uneasy sense that this might generate something that would cause the HTML to fail validation, or maybe generate unstyled content.  Do you have a pretty tight limit on the number of extra fields?
Avatar of Eternal_Student

ASKER

This worked just fine actually.