我有一个文本区域,同事在其中输入不带扩展名的文件名,然后返回。我的代码采用这个输入列表并创建一个名为$list
. 然后它将获取该数组并创建一个更新的数组,该数组$genList
使用额外的文件名调用,如下所示:
$fileString = $_POST['fileList'];
$unique = $_POST['unique'];
$size = $_POST['size'];
$generateArray = $_POST['generateArray'];
$list = explode("\r\n",$fileString);
if ($generateArray == "yes") {
if ($size == "5x7inimpos") {
$genList = array();
foreach($list as $element) {
array_push($genList, $element . "_f", $element . "_b", $element . "_i");
}
}
$list = array();
$list = $genList;
}
就目前而言,如果工作人员输入一些文件名,如下所示:
HOL_12_001_00
HOL_12_002_00
HOL_12_003_00
它最终将被转换为文件名末尾带有扩展名的数组,如下所示:
$list = array(HOL_12_001_00_f, HOL_12_001_00_b, HOL_12_001_00_i, HOL_12_002_00_f, HOL_12_002_00_b, HOL_12_002_00_i, HOL_12_003_00_f, HOL_12_003_00_b, HOL_12_003_00_i);
但我真正需要做的是在文件名中包含最终数组(带有_f
, _b
, _i
),如下所示:
$list = array(HOL_12_f_001_00, HOL_12_b_001_00, HOL_12_i_001_00, HOL_12_f_002_00, HOL_12_b_002_00, HOL_12_i_002_00, HOL_12_f_003_00, HOL_12_b_003_00, HOL_12_i_003_00);
我怎样才能做到这一点?