在以下行获取数组到字符串的转换错误:$sub= $foldername。/'.$check[$x];.请指教



我是PHP的新手。在这里,我尝试根据表单的输入创建父文件夹和子文件夹。我正在以下行获取数组到字符串的转换错误:$sub= $foldername。/'.$check[$x];.请指教。

//Creating the parent and sub folder
$checked_count1=5;
$foldername = $_POST['foldername'];
$structure = dirname(__FILE__).DIRECTORY_SEPARATOR.$foldername;
if (!mkdir($structure, 0777, true)) {
die('Failed to create folders...');
}
//Subfolder
for($x=0;$x<$checked_count1;$x++)
{
$sub= $foldername.'/'.$check[$x];
if(!file_exists($sub)){
mkdir($sub, 0777);
}
}

即使$check没有在给定的代码中设置,php prpbably 也会认为 $check[$x] 的值是一个数组。此外,您将此数组连接到字符串,因此数组到字符串的转换错误。 只能连接字符串。如果可能,php 会先将其他类型值转换为字符串。这对于数组是不可能的。

最新更新