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

Php 在以下行获取数组到字符串的转换错误:$sub=$foldername.'/'$支票[$x];。请指教,php,Php,我是PHP新手。在这里,我试图根据表单的输入创建父文件夹和子文件夹。我在以下行获取数组到字符串的转换错误:$sub=$foldername.'/'.$check[$x];。请给我一些建议 //Creating the parent and sub folder $checked_count1=5; $foldername = $_POST['foldername']; $structure = dirname(__FILE__).DIRECTORY_SEPARATOR.$folde

我是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);
   }
   }
//创建父文件夹和子文件夹
$checked_count1=5;
$foldername=$_POST['foldername'];
$structure=dirname(_文件__).DIRECTORY_分隔符。$foldername;
如果(!mkdir($structure,0777,true)){
die('未能创建文件夹…');
}
//子文件夹

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

在您提供的代码中,
$check
从未设置过。您好,如果我按以下方式更改代码,会怎么样?//($x=0;$xI)的子文件夹无法判断,因为我不知道$check[$x]的值。如果是数组,它将无法工作。请将var_dump($check);放在给定代码的顶部,然后发布输出,以便我可以看到它的值。