beginner programmer here. 

I have pictures in a directory that are pushed into an array

```
$pressImages = scandir('img/press');

```

then sliced to remove system files

```
$slice = array_slice($pressImages, 3);

```

then run through a loop to print out each image on to the webpage

```
foreach ($slice as $image) {
 echo "<div class='press list-item'><img src='img/press/$image' /></div>";
}

```

I would like to add anchor tags to the first four iterations of the loop (each Link is unique), but not to the others. I'm trying to learn how to consolidate instructions to the smallest number possible. Would I need to create two separate loops here? I was thinking I would create two directories, one for images that have links, and the other for images without links, with each having their own foreach loop, but my intuition suggests there might be a more efficient way.

Thanks for the help in advance!

\*\*Some wonderful suggestions everyone thanks again, learning so much. I've been unable to try these out myself so am relying on visualizing them. I will be sure to select an answer soon