0

I have this loop:

$dir = 'url/dir/dir/'; 
$images_array = glob($dir.'*.jpg'); 
foreach ($images_array as $image) {
     $image = str_replace($dir, '', $image);   
}  

I just want to save the $image variables into a new array. How is this possible?

theorise
  • 7,245
  • 14
  • 46
  • 65

1 Answers1

4
$dir = 'url/dir/dir/'; 
$images_array = glob($dir.'*.jpg'); 

$images = array();

foreach ($images_array as $image) {
     $images[] = str_replace($dir, '', $image);   
}

var_dump($images);
hsz
  • 148,279
  • 62
  • 259
  • 315