从数组创建php文件

从数组创建php文件,php,Php,执行以下代码时,将创建一个文件NewFileName.php 它还将向页面添加内容,包括在我有$pagename的内容中添加新文件名 这一切都是可行的,但我的问题是,我可以从一个数组中创建多个文件吗 比如说 $pagename = array(“fileone”,”filetwo”,”filethree”,”filefour”); 是的,你可以。PHP提供了一种在给定数组中循环并为该数组中的每个项执行操作的方法 例如: // Please note that I've changed th

执行以下代码时,将创建一个文件NewFileName.php 它还将向页面添加内容,包括在我有$pagename的内容中添加新文件名

这一切都是可行的,但我的问题是,我可以从一个数组中创建多个文件吗

比如说


$pagename = array(“fileone”,”filetwo”,”filethree”,”filefour”);


是的,你可以。PHP提供了一种在给定数组中循环并为该数组中的每个项执行操作的方法

例如:

// Please note that I've changed the variable name to the plural version of the word.
$pagenames = array("fileone","filetwo","filethree","filefour");
foreach($pagenames as $pagename) {
    // Do some stuff here.
}
请看这里:

还有这里:

// Please note that I've changed the variable name to the plural version of the word.
$pagenames = array("fileone","filetwo","filethree","filefour");
foreach($pagenames as $pagename) {
    // Do some stuff here.
}