Hello i try to make this
I have variable with this
$var = 'text;text2;text3';
I want after ; to split on new line with foreach i want to make something like this
$var = 'text1;text2;text3';
// here is splitter or anything i dont know
foreach($var as $i) {
echo $i;
}
Output will be
text1
text2
text3
答案 0 :(得分:0)
You can use explode()
to do this:
$var = 'text;text2;text3';
$cmds = explode(';', $var) ;
foreach ($cmds as $cmd) {
// echo $cmd ; // do something with $cmd
$rcon->sendCommand($cmd) ;
}