Apologies, I screwed up on title and question, I believe both are now fixed. It looked like I was looking for "OR", whereas I am looking for "AND".
I have several files in a folder:
this-is-big-needle1.jpg
a-big-long-needle1.jpg
this-file-is-needle2.jpg
needle3-is-this-file.jpg
The current code && strpos($file,"needle1") is used to search a folder and inlcude all files that that match the strops value eg "needle1" and include these images in an AMP HTML carousel.
So current code searches for "needle1" and will correctly return the first 2 files above but ignore the others.
I have searched and found several general solutions for finding if needle1 OR needle2 are present in filename, but found nothing were both "big" and "needle1" are found in the same filename.
I have tried adding a second strops && strpos($file, "needle1") && strpos($file, "big") but my php skills are very lacking so get easily tripped up with syntax and were to put eg '..' etc
php
$Count5Image5 = 0;
$Image5;
$handle = opendir(dirname(realpath(__FILE__)).'/images/');
while($file = readdir($handle)){
if($file !== '.' && $file !== '..' && strpos($file,"needle1"))
{
Image5[$Count5Image5] = $file;
$Count5Image5++;
}
}
sort($Image5);
for($i=0; $i<$Count5Image5; $i++)
echo '<amp-img src="images/'.$Image5[$i].'" class="xs-12" width="353" height="210" layout="responsive"></amp-img>';
?>
If someone could suggest an edit of my code to find "big" & "needle1" in the same filename (to return top two files) it would be appreciated.
========== A litte side issue (in case there is an obvious solution) - for some reason existing code will not find any file if the strops value is at the start of the file name eg if I enter value "this-" it will not find any files or if I enter needle3 it will not find any files (string must be after character1 in the string)