$ekipa = "Admini-aruturek,Kura126"
$rangi = explode('-', $ekipa);
foreach ($rangi as $ranga){ #I know that is no correct.
echo($ranga[1]); #This is not correct!
echo($ranga[2]); #This is not correct!
}
好的,我想将字符串的第一部分和第二部分分开。例如
库拉(Kura)Admini-aruturek126
至
阿迪米尼
和
库拉,aruturek
从“ Admini-aruturek,Kura126”到:
回显“ Admini”;
回声“ aruturek,Kura126”
怎么做?
最佳答案
这不是你的意思吗?您说团队名称是Admini,但然后又说要与Kura126一起显示aruturek吗?
$ekipa = "Admini-aruturek,Kura126";
$rangi = explode(',', $ekipa);
foreach ($rangi as $ranga) {
if (strstr($ranga, '-') !== false) {
list($name, $name2) = explode('-', $range);
} else {
$name = $ranga;
}
echo $name . "<br/>";
}