你好,我的剧本里有这个数组。这是我的阵列
Array
(
[0] => Array
(
[0] => BACK
[1] => PACK
[2] => BBP160800103
[3] =>
[4] => G086-1
[5] => 8#.JPG
)
[2] => Array
(
[0] => BACKPACK
[1] => BBP160500010
[2] => G114-3#1.JPG
)
[3] => Array
(
[0] => WSL160800024-WSL160800025
[1] => L83-5.JPG
)
[4] => Array
(
[0] => IA041017
[1] => L83-5.JPG
)
)
我从这个脚本得到数组。我在用编码器3
public function generatenewname(){
$this->load->helper('directory');
$map = directory_map( './assets/file_upload/md/temp/',FALSE, TRUE);
for($x=0;$x<count($map);$x++){
$newest[$x] = explode(" ",$map[$x]);
}
echo "<pre>";print_r($newest);
}
所以从上面的数组中,我想得到这个值
BBP160800103,BBP160500010,WSL160800024,WSL160800025
和IA041017
如何实现它?--更新——
我从我的脚本中做了一些更新(我正在尝试)
public function generatenewname(){
$this->load->helper('directory');
$map = directory_map( './assets/file_upload/md/temp/',FALSE, TRUE);
for($x=0;$x<count($map);$x++){
$newest[$x] = explode(" ",$map[$x]);
for($y=0;$y<count($newest[$x]);$y++){
if(strlen($newest[$x][$y]) >= 7){
$file[] =$newest[$x][$y];
}
}
}
for($x=0;$x<count($file);$x++){
echo $x.' '. $file[$x].'<br>';
}
}
上面的剧本我把它列在我的单子上
[n] BBP160800103
[n] BBP160500010
[n] WSL160800024-WSL160800025
我想实现它
[n] BBP160800103
[n] BBP160500010
[n] WSL160800024
[n] WSL160800025
最佳答案
将最后一个数组传递给此函数以获得结果。
arraymakking($file);//your array
function arraymakking($arr){
foreach($arr as $key=>$val){
if(strpos($val,'-') !== false){
$res=explode('-',$val);
unset($arr[$key]);
}
}
$result=array_merge($arr,$res);
return $result;
}