2

example I have table with column like this :

L1 | L2 | L3 | L4 | L5
2  |    | 1  |    |

I want, if 1 of the 5 columns filled with value then will do something.

In PHP code so far :

<?php

//query to get all value of column
while ($data = oci_fetch_array($//query))
{
$l1 = $data['L1'];
$l2 = $data['L2'];
$l3 = $data['L3'];
$l4 = $data['L4'];
$l5 = $data['L5'];
}

//How can I check if 1 of the 5 column filled ?
if(bla bla)
{
}
4

2 回答 2

6

您可以使用array_filter()来确定数组中是否有任何非空值:

if (count(array_filter($data))) {
  // there's something inside
}

要找出哪些值被认为是非空的,请查看此转换表

于 2013-10-03T02:10:36.610 回答
1
if (is_null($variable){
//do something
}
于 2013-10-03T02:12:29.613 回答