The issue here is that when I do print_r after I create the array with $picnameoutput it prints the array as you will see in the screenshot.
Later after I run the for loop and echo it just to see the output it only gives me 1 value and I can’t figure out why it picks that value, it is not even the first one in the array.
Very Frustrated.
Here is my code
<?php
$largedir = 'images/headshots/large';
$large = scandir($largedir);
$picnameoutput = preg_grep("/adam.*/", $large);
print_r($picnameoutput);
for ($i=0; $i<count($picnameoutput); $i++); {
echo "$picnameoutput[$i]";
}
?>
And here is a screenshot so you can see what I mean

You have a semicolon
;afterfor()before bracket. Remove it.So
becomes
however I would recommend to use
foreach()insteadwhich is pretty easy to use and even faster than your for loop