I need to retrieve images from a folder and only have the reference number written to the database. Also I have to create an increment, because for each reference can have n images.
By combining the scandir and strstr functions of PHP I can recover, but despite correctly printing what I need, in example 1 , it does not filter the other results, making it difficult to create the correct increment, such as photo-1- ... photo-2- ... etc.
By adding the line break you notice the other hidden results, making the increment catch all results of the folder. Thanks for any help.
Images are saved like this: Ex: photo-1-0023.jpg, photo-2-0023.jpg
$dir = '../assets/Imagens/';
$files = scandir($dir);
foreach ($files as $key => $value) :
$conta=1;
//$domain = strstr($value, "foto-".$conta++."-".$row['referencia']);
// Exemplo 1
$domain = strstr($value, $row['referencia']);
echo $domain ;
// imprime 00234.jpg00234.jpg00234.jpg00234.jpg00234.jpg00234.jpg (6 imagens)
echo $domain.'<br>' ;
//imprime 00234.jpg
//00234.jpg
//00234.jpg
//00234.jpg
//00234.jpg
//00234.jpg
endforeach;