1

我的 HTML

    <input type="textbox" name="bus[]" value="">
    <input type="textbox" name="bus[]" value="">
    <input type="textbox" name="bus[]" value="">
    <input type="textbox" name="bus[]" value="">

我的脚本

$busac = $_post[bus];
$busaccount = count($busac);
    if($busaccount != 0){
    for($bc=0;$bc<$busaccount;$bc++){
        $acbusmodel[]=array('bus'=>array('busmodel'=>array('local'=>$busrsac[$bc],'others'=>$busdollar[$bc])));
    } // endforeach
    }

foreach($acbusmodel as $key=>$value) {
            $values[$key] = $value;
            $acvalue .= $value;
            print_r($value);
        }
Array ( [0] => Array ( [bus] => Array ( [busmodel] => Array ( [local] => 1 [others] => 1 ) ) ) [1] => Array ( [bus] => Array ( [busmodel] => Array ( [local] => 2 [others] => 2 ) ) ) [2] => Array ( [bus] => Array ( [busmodel] => Array ( [local] => 3 [others] => 3 ) ) ) )

上面是显示代码

我想要这样的代码

Array ( [bus] => Array ( [busmodel] => Array ( [local] => 1 [others] => 1 ) ) ) Array ( [bus] => Array ( [busmodel] => Array ( [local] => 2 [其他] => 2 ) ) ) 数组 ( [bus] => 数组 ( [busmodel] => 数组 ( [local] => 3 [others] => 3 ) ) )

我想将值保存在单个字符串中..

4

3 回答 3

1

如果我理解正确,这就是您所需要的

代替print_r($value)

$c = count($value);
$fin='';
for($ i =0;$i<$c;$i++)
{

    $fin .=print_r($value[i],true); // this will print to variable (not on browser)

}
于 2013-05-10T10:29:19.983 回答
0

替换 print_r($value); 使用以下代码

 $new_value=array();
  foreach($value as $data){
    array_push($new_value, $data);
  }
 $value=$new_value;
 print_r($value);
于 2013-05-10T10:39:17.670 回答
0

使用前一个数组创建另一个数组

$newarray = $oldarray[0];
于 2013-05-10T10:30:48.143 回答