跳过爆炸的第一个字符
Skip the first characters form explode
我想展开如下所示的一些文件名,但不想展开第一个 "iw5_m4a1_mp"
我需要跳过 "iw5_m4a1_mp" 那我该怎么做呢?!
我在 return 数组中也有问题,它只是 return 的第一个数据?
$weapon = iw5_m4a1_mp_eotech_silencer_texture;
function getWeaponThu($weapon = null) {
$ThuName = $weapon;
$spiltthum = explode('_', $ThuName);
foreach($spiltthum as &$t){
$ThuPath = "/img/";
$ThuImg = $ThuPath . $t . ' .jpg ';
return $ThuImg;
}
}
来自评论:
there are always three values at the start of the file name but not always iw5_m4a1_mp the middle part is different like this iw5_pp90_mp i just want to skip three values at the start
$weapon = 'iw5_m4a1_mp_eotech_silencer_texture';
function getWeaponThu($weapon = null) {
if (!$weapon)
return;
$spiltthum = explode('_', $weapon);
$ThuImg = [];
for ($i = 3; $i < count($spiltthum); $i++)
array_push($ThuImg,'/img/' . $spiltthum[$i] . '.jpg');
return $ThuImg;
}
print_r(getWeaponThu($weapon));
打印:
Array
(
[0] => /img/eotech.jpg
[1] => /img/silencer.jpg
[2] => /img/texture.jpg
)
我想展开如下所示的一些文件名,但不想展开第一个 "iw5_m4a1_mp" 我需要跳过 "iw5_m4a1_mp" 那我该怎么做呢?! 我在 return 数组中也有问题,它只是 return 的第一个数据?
$weapon = iw5_m4a1_mp_eotech_silencer_texture;
function getWeaponThu($weapon = null) {
$ThuName = $weapon;
$spiltthum = explode('_', $ThuName);
foreach($spiltthum as &$t){
$ThuPath = "/img/";
$ThuImg = $ThuPath . $t . ' .jpg ';
return $ThuImg;
}
}
来自评论:
there are always three values at the start of the file name but not always iw5_m4a1_mp the middle part is different like this iw5_pp90_mp i just want to skip three values at the start
$weapon = 'iw5_m4a1_mp_eotech_silencer_texture';
function getWeaponThu($weapon = null) {
if (!$weapon)
return;
$spiltthum = explode('_', $weapon);
$ThuImg = [];
for ($i = 3; $i < count($spiltthum); $i++)
array_push($ThuImg,'/img/' . $spiltthum[$i] . '.jpg');
return $ThuImg;
}
print_r(getWeaponThu($weapon));
打印:
Array
(
[0] => /img/eotech.jpg
[1] => /img/silencer.jpg
[2] => /img/texture.jpg
)