-1
我想获得在从用户输入形式的阵列中的每个项目。由空间(1 2 3 4)中分离单个输入字段,用户将输入数字然后我得到该输入和替换用逗号(1,2,3,4)的空间和该变量添加到阵列然而由返回的结果$数量似乎返回整个价值为单个数字是这样的:获取每个项目阵列中的从用户输入中
1,2,3,4
,而不是像这样:
1
2
3
4
代码:
<?php
$inp_results =$_POST['inp_results'];
$inp_results_comma = str_replace(' ', ',', $inp_results);
$number_in_results = array($inp_results_comma);
foreach ($number_in_results as $number)
{
echo "$number</br>";
}
为什么不只是在[空间] [爆炸](http://php.net/manual/en/function.explode.php)? – FirstOne
'$ string ='1 2 3 4'; $ result = explode('',$ string);的foreach($结果作为$数){ 回声 “$号”; }“是吗? –