Php 如何删除要保存在字符串中的数组中的键
我的HtmlPhp 如何删除要保存在字符串中的数组中的键,php,jquery,html,Php,Jquery,Html,我的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
<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 ) ) ) )
$busac=$\u post[bus];
$busaccount=计数($busac);
如果($busaccount!=0){
对于($bc=0;$bcarray($busmodel'=>array('local'=>$busrsac[$bc],'others'=>$busdaular[$bc]));
}//endforeach
}
foreach($acbusmodel作为$key=>$value){
$values[$key]=$value;
$acvalue.=$value;
打印(价值);
}
阵列([0]=>阵列([bus]=>Array([busmodel]=>Array([local]=>1[others]=>1)))[1]=>Array([busmodel]=>Array([busmodel]=>2[others]=>2])[2]=>Array([busmodel]=>Array([busmodel]=>Array([local]=>3[others]=>3]))
上面是显示代码
我想要这样的代码
Array ( [bus] => Array ( [busmodel] => Array ( [local] => 1 [others] => 1 ) ) ) Array ( [bus] => Array ( [busmodel] => Array ( [local] => 2 [others] => 2 ) ) ) Array ( [bus] => Array ( [busmodel] => Array ( [local] => 3 [others] => 3 ) ) )
阵列([bus]=>Array([busmodel]=>Array([local]=>1[others]=>1)))阵列([bus]=>Array([busmodel]=>2[others]=>2)))阵列([bus]=>Array([local]=>3[others]=>3)))
我想用单个字符串保存该值 如果我理解正确,这就是你需要的 替换打印($value) 与
$c=计数($value);
$fin='';
对于($i=0;$i如果我理解正确,这就是您需要的
替换打印($value)
与
$c=计数($value);
$fin='';
对于($i=0;$i使用上一个数组创建另一个数组
$newarray = $oldarray[0];
使用上一个数组创建另一个数组
$newarray = $oldarray[0];
将print\r($value);替换为以下代码
$new_value=array();
foreach($value as $data){
array_push($new_value, $data);
}
$value=$new_value;
print_r($value);
将print\r($value);替换为以下代码
$new_value=array();
foreach($value as $data){
array_push($new_value, $data);
}
$value=$new_value;
print_r($value);
阵列无法按您的要求工作。您要保存此值:Array([bus]=>Array([busmodel]=>Array([local]=>1[others]=>1)))Array([bus]=>Array([busmodel]=>Array([local]=>2[others]=>2)))Array([bus]=>Array([busmodel]=>Array([local]=>3[others]=>3]))
在单个字符串中???为什么要在字符串中“保存”数组?是否尝试以特定格式序列化?数组无法按您所需工作。要保存此值:数组([bus]=>array([busmodel]=>array([busmodel]=>1[others]=>1)))数组([bus]=>array([busmodel]=>array([local]=>2[others]=>2))数组([bus]=>Array([busmodel]=>Array([local]=>3[others]=>3))
在单个字符串中???为什么要在字符串中“保存”数组?是否尝试以特定格式序列化?请检查我想要字符串中的循环数组我想你不明白我的意思question@faizphp这是阵列([bus]=>阵列([busmodel]=>阵列([local]=>1[others]=>1)))阵列([bus]=>Array([busmodel]=>Array([local]=>2[others]=>2)))阵列([bus]=>Array([busmodel]=>Array([local]=>3[others]=>3)))
所需的o/p?如果不是什么?您是否检查了$acvalue。=$value;我这样输入,但它显示为singlearray@YogeshSuthar如果你没有给出第二个参数true
你是对的。如果你给出true
它将打印到变量中。请参考检查我想要一个字符串中的循环数组我想你没有理解我的question@faizphp这是阵列([bus]=>Array([busmodel]=>Array([local]=>1[others]=>1)))阵列([bus]=>Array([busmodel]=>2[others]=>2)))阵列([bus]=>Array([busmodel]=>Array([local]=>3[others]=>3]))
所需的o/p?如果不是什么?您是否检查了$acvalue。=$value;我这样输入,但它显示为singlearray@YogeshSuthar如果你没有给出第二个参数true
你是对的。如果你给出true
它将打印到变量中。请参考否我不想要这个数组([bus]=>Array([busmodel]=>阵列([local]=>1[others]=>1)))阵列([bus]=>Array([busmodel]=>Array([local]=>2[others]=>2)))阵列([bus]=>Array([busmodel]=>3[local]=>3[others]=>3)))我想要的总阵列loop@faizphp:他的代码将删除第一个索引,即[0]不,我不想要这个数组([bus]=>array([busmodel]=>array([busmodel]=>1[local]=>1[others]=>1)))数组([bus]=>array([busmodel]=>array([local]=>2[others]=>2)))数组([bus]=>array([busmodel]=>array([local]=>3[others]=>3]))我要在字符串中输入的总数组loop@faizphp:他的代码将删除第一个索引,即[0],并将只对所需的剩余部分进行o/p…但它还是一个数组。