从网页获取文件并使用file_put_contents保存

I tried making a script that could save all files from a webpage with a pattern in name to a server.

<?php

$base_url = "http://www.someurl.com/";
$sufix = ".jpg";
$id_start= "Name Numberstart"; //Picture 1 
$id_end = "Name Numberend"; // Picture 235
$path_to_save = "filer/";

foreach(range($id_start, $id_end) as $id) {
    file_put_contents($path_to_save.$id.$sufix, file_get_contents($base_url.$id.$sufix));
}

?>

If I only use id with numbers etc. 1-20 or 50 - 60 and so on, the script works perfectly. But when I have a name in front and white space, it doesn't seem to work. It just saves 1 file and stops.

According to php.net's description of range:

Character sequence values are limited to a length of one. If a length greater than one is entered, only the first character is used.

I take that to mean that

range("Name Numberstart", "Name Numbersend") == array("N");

And if we run php interactively, this is confirmed:

php > $var = range("Name Numberstart", "Name Numbersend");
php > var_dump($var);
array(1) {
  [0]=>
  string(1) "N"
}

So basically, you're actually getting the range of the first character of the first word to the first character of the second word. If we change the second word to "Pretty", we get:

php > var_dump(range("Name Numberstart", "Pretty Numbersend"));
array(3) {
  [0]=>
  string(1) "N"
  [1]=>
  string(1) "O"
  [2]=>
  string(1) "P"
}