我的代码是2个部分,主要包含重要的PHP代码(身体),第二打印输出(如HTML)打印所有的foreach结果
我不能让一个在...输出必须在第二部分
第一部分打印为html
<?php
// The main code
$w = explode('-', 'x1-x2-x3-x4');
foreach($w as $n) {
$s1 = $n;
}
?>
第二
<?php
// Print output here and must be here
echo $s1;
?>
正如你所看到的,我想了解foreach循环的输出,它应该是
x1
x2
x3
x4
但我只得到了x4
。为什么?
你说的*部分的意思是*?文件?代码块? – Shoe
no does not work..syntax error – user2203703
他的意思是'$ s1 = $ n'。 – casraf