Home > Backend Development > PHP Tutorial > 请问:PHP中,怎么获取提交的二维数组中某几列键值不为空的结果

请问:PHP中,怎么获取提交的二维数组中某几列键值不为空的结果

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:03:26
Original
987 people have browsed it

请教: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 />)
Copy after login


<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 />
Copy after login

我想得到的最终结果是。name中数值不为空,且pronum数值不为空的结果。试了下if( $v2!=' ) 不对。特请教各位。谢谢了
------解决方案--------------------

<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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template