I've found the solution.
I was trying to output 12 images from different contents. Each contents has got more than one image using one image field with number of value "unlimited".
I was trying using View PHP module and adding something like this
$counter = 0;
foreach ($row->field_image as $image){
if ($counter++ == 8){
echo "something";
continue;
}
if ($counter++ == 11){
echo "something else";
continue;
}
print $images;
}
But I was getting just numbers 1 and 2 (probably the node id, I've got just two nodes for the moment.)
I start to go around the web with no result so I've started to play around with fields and the view theme (views-view-unformatted--portfolio--page-2.tpl.php).
I found one problem there, each group of images of one node was in one row but I should have one image per row, does not matter if they were from the same content (I've got random sort criteria). So I went into the view, I clicked on the image field and under "Multiple field settings" I dunchecked "Display all values in the same row " so I could get them in different rows. I edited the views-view-unformatted--portfolio--page-2.tpl.php in this way
<?php
$counter = 0;
foreach ($rows as $id => $row) {
$counter++;
print '<div class="'.$classes_array[$id].'">';
if ($counter == 8) {
print 'Something';
} elseif ($counter == 11) {
print 'Something else';
} else {
print $row;
}
print '</div>';
}
?>
Here we go. I've got the thing I wanted without using the View PHP.
Thanks to David Meister for suggesting me to put the $counter++ outside the if statement, it works much much better.