Php rename functions cannot be used. how can this problem be solved?
Source: Internet
Author: User
Php rename functions cannot be used & lt ;? Php & nbsp; // The rename function saved as UseFile5_for_rename.php & nbsp; $ filepath = & quot; C:/Users/Administrator/Desktop/New Folder/& q php cannot be used
// Save as UseFile5_for_rename.php
$ Filepath = "C:/Users/Administrator/Desktop/New Folder /";
$ Readarray = file ($ filepath. "synopsis .txt ");
$ Sign1 = "th ";
$ Sign2 = "set ";
$ NameArray = array ();
If (! $ Readarray ){
Echo "an error occurred while reading the file using the file function.
";
}
Else
Foreach ($ readarray as $ value ){
If (strstr ($ value, $ sign1) & strstr ($ value, $ sign2 ))
// Note the byte of Chinese characters when using strpos
Array_push ($ nameArray, $ value );
// Else echo "cannot be found ";
}
Echo sizeof ($ nameArray )."
";
// Rename the object in order
$ I = 1;
Foreach ($ nameArray as $ value ){
$ Value = trim ($ value); // required
Echo $ value ."
";
$ Filename = $ filepath. "(". $ I. ")". ". txt ";
$ Value = $ filepath. $ value. ". txt ";
Rename ($ filename, $ value );
$ I ++;
If ($ I> 10) break; // total number of files in the folder
}
// Rename the file by ing
Echo "";
?>
------------------------------------------------------- Running result:
86
1st episode Hong Taiwei mistaken the demon
Warning: rename((1).txt, 1st sets Hong Taiyun mistaken for the Demon .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
2nd Qixing Juyi, Shiji village
Warning: rename((22.16.txt, 2nd .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
3rd sets of nine lines of Dragon private go to Yan'an government
Warning: rename((32.16.txt, 3rd sets Jiuji nanyuanfu .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
July 4th
Warning: rename((42.16.txt, 4th sets Lu to promote Jin Cuilian .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
5th-episode boxing in Kansai
Warning: rename((52.16.txt, 5th sets boxing town customs .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
Yunshu Temple, Shudu, Ruda, 6th
Warning: rename((62.16.txt, February Luda shaving wenshusi .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
The first episode of leopard was accidentally entered the white tiger Hall
Warning: rename((72.16.txt, 7th set leopard head mistaken into the White Tiger classroom .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
8th sets
Warning: rename((8).txt, 8th sets reverse-directed Willow .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
9th sets of wild pig forests
Warning: rename(92.16.txt, 1st episode, dashboard, forest) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
10th episode Lin Chong flood
Warning: rename((102.16.txt, 10th sets Lin Chongbang flood tutorial .txt) [function. rename]: No error in R: \ Program Files \ AppServ \ www \ filetest \ UseFile5_for_rename.php on line 30
----------------------------
/*
Because the current path is the file path of UseFile5_for_rename.php, I want to modify the 10 files in the $ filepath Directory:
Original name: (idomain.txt (I =, 3..., 10 );
If you want to cut the file to the current path, use:
$ Filename = "(". $ I. ")". ". txt ";
$ Value = $ value. ". txt ";
Rename ($ filename, $ value );
Yes
So why cannot it be in an absolute path?
*/
------ Solution --------------------
This seems to be a bug in php5.3. haven't it been corrected yet?
------ Solution --------------------
Whether permission is required. no permission is set. It's not very clear, is it said upstairs?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.