Using a variable inside a print I have the following code:

print $node-&gt;field_carousel_1[0]['filepath'];


What I would like to do is changing the 1, and use a variable instead.

Do you have any idea how I would be able to do this?

What I am aiming for is using a variable to create a looping function to print
"field_carousel_1," "field_carousel_2," "field_carousel_3," etc.
You can just change the 1 to your particular variable in the loop.

Example:

foreach ($values as $k =&gt; $v) {
  print $node-&gt;field_carousel_ . $v . [0]['filepath'];
}


That should output the values you need.