开发者

PHP, putting a looping variable from a foreach loop into a new array

开发者 https://www.devze.com 2023-02-14 16:24 出处:网络
I have this loop: $dir = \'url/dir开发者_StackOverflow/dir/\'; $images_array = glob($dir.\'*.jpg\');

I have this loop:

$dir = 'url/dir开发者_StackOverflow/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?


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

$images = array();

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

var_dump($images);
0

精彩评论

暂无评论...
验证码 换一张
取 消