php – 检查数组是否不为空
发布时间:2020-12-13 14:04:12 所属栏目:PHP教程 来源:网络整理
导读:********更新********** var_dump:string(0)“” 我正在尝试检查数组的一部分是否不为空,然后显示代码,但代码显示无论如何. 我试过!is_null!空.我不确定哪个应该是正确的,或者我应该去: if(sizeof($book [‘Booking’] [‘comments’]) 0) 码: ?php if
********更新**********
var_dump:string(0)“” 我正在尝试检查数组的一部分是否不为空,然后显示代码,但代码显示无论如何. 我试过!is_null!空.我不确定哪个应该是正确的,或者我应该去: 码: <?php if (!empty($book['Booking']['comments'])) {?> <table width="100%" border="0"> <tbody> <tr> <td style="font-family:'Lucida Grande',sans-serif;font-size:12px;font-weight:normal;color:#666666;"> <?=$book['Booking']['comments']?> </td> </tr> </tbody> </table> <? } ?> 阵: Array ( [Booking] => Array ( [id] => 109 [user_id] => 1 [corporate_account_id] => 0 [id_ref] => RES000109 [price] => 178.00 [arrival] => 2011-10-18 00:00:00 [departure] => 2011-10-19 00:00:00 [rate_title] => [adult_guests] => 4 [child_guests] => 0 [company] => gravitate [titlename] => [firstname] => SEOn [surname] => Gleeson [address1] => 8 Crow St [address2] => [city] => Dublin [state] => Co. Dublin [postcode] => 2 [country] => Ireland [phone] => 0863269087 [mobile] => [fax] => [email] => ger@res360.com [comments] => [created] => 2011-10-18 13:40:47 [updated] => 2011-10-18 13:40:47 [status] => 1 [cancelled] => 0 [request_src] => website [request_token] => 0 [token] => ayzrGnx [survey_sent] => 0000-00-00 00:00:00 [survey_returned] => 0000-00-00 00:00:00 [send_sms] => 0 [payment_time] => 0000-00-00 00:00:00 [fullname] => SEOn Gleeson )
我怀疑它可能包含(bool)FALSE,这对于is_null()是不正确的.
尝试简单地: if ($book['Booking']['comments']) { 这也适用于评估为FALSE的任何内容,如空字符串. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |