Rumah >pembangunan bahagian belakang >tutorial php >请问:PHP中,怎么获取提交的二维数组中某几列键值不为空的结果
请教:PHP中,如何获取提交的二维数组中某几列键值不为空的结果
所提交的结果如下:
Array<br />(<br /> [name] => Array<br /> (<br /> [0] => 地砖<br /> [1] => <br /> [2] => 空心砖<br /> [3] => 地砖<br /> )<br /><br /> [cunit] => Array<br /> (<br /> [0] => 块<br /> [1] => <br /> [2] => 块<br /> [3] => 块<br /> )<br /><br /> [unitprice] => Array<br /> (<br /> [0] => 35<br /> [1] => <br /> [2] => 3.5<br /> [3] => 35<br /> )<br /><br /> [pronum] => Array<br /> (<br /> [0] => 2<br /> [1] => <br /> [2] => 2<br /> [3] => <br /> )<br /><br /> [summoney] => Array<br /> (<br /> [0] => <br /> [1] => <br /> [2] => <br /> [3] => <br /> )<br /><br />)
<br /> $data=$_POST['sale'];<br /> //print_r($data);<br /><br /> foreach ($data as $k1 => $v1) {<br /> foreach ($v1 as $k2 => $v2) {<br /> $new_data[$k2][$k1] = $v2;<br /> $new_data[$k2]['username']='admin';<br /> }<br /> }<br /><br />
<br>$arr=array<br>(<br> 'name' => array<br> (<br> 0 =>'地砖',<br> 1 =>'',<br> 2 => '空心砖',<br> 3 => '地砖',<br> ),<br> 'cunit' => array<br> (<br> 0 => '块',<br> 1 => '',<br> 2 => '块',<br> 3 => '块'<br> ),<br> <br> 'unitprice' => array<br> (<br> 0 => 35,<br> 1 => '',<br> 2 => 3.5,<br> 3 => 35<br> ),<br> <br> 'pronum' => array<br> (<br> 0 => 2,<br> 1 => '',<br> 2 => 2,<br> 3 =>''<br> ),<br> 'summoney' => array<br> (<br> 0 =>'', <br> 1 =>'', <div class="clear"> </div>