0
I need to recover images from a folder and I only have the reference number recorded in the database. I also have to create an increment, because for each reference can have n images.
Combining the functions scandir and strstr of PHP I can recover, but despite printing correctly what I need, in case the 6 images as in example 1 "$Domain", it does not filter the other results, making it difficult to create the right increment, type photo-1- ... photo-2- ... etc.
Adding the line break if you notice the other hidden results, making the increment grab all results from the folder. I appreciate any solution.
The images are saved as follows: 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;
OK thanks @Daneil Costa, I’m doing tests and as soon as we can we continue.
– denis