我有一系列文件和文件夹。这是数组
array("index.php","/examples","/myproject","scan.php","/wordpress","background.png","script.js");
我只想将数组显示为
FILES
index.php
scan.php
background.png
script.js
FOLDER
/examples
/myproject
/wordpress
我的问题是我可以分开文件和文件夹吗?我来到这里可以有人帮我吗?提前致谢
答案 0 :(得分:2)
$array = array("index.php","/examples","/myproject","scan.php","/wordpress","background.png","script.js");
$files = [];
$dirs = [];
foreach($array as $filename) {
if (strpos($filename, '.') === false) {
$dirs[] = $filename;
} else {
$files[] = $filename;
}
}
// Output: $files, $dirs
答案 1 :(得分:1)
glEnable(GL_TEXTURE_2D);
texture= LoadTexture( "texture.bmp" );
glBindTexture (GL_TEXTURE_2D, texture);
solidCube(1);
答案 2 :(得分:1)
$array = array("index.php","/examples","/myproject","scan.php","/wordpress","background.png","script.js");
$files = [];
$folders = [];
foreach($array as $value) {
if (strpos($value, '/') === false) {
$files[] = $value;
}
else {
$folders[] = $value;
}
}
答案 3 :(得分:1)
$array = array("index.php","/examples","/myproject","scan.php","/wordpress","background.png","script.js");
$file = $dir = [];
foreach($array as $filename) {
if (strpos($filename, '.') === false) {
$dir[] = $filename;
} else {
$file[] = $filename;
}
}
如果你把这个
var_dump($file);
var_dump($dir);
OUTPUT
array("index.php","scan.php","background.png","script.js")
array("/examples","/myproject","/wordpress")