php – 检查数组是否不为空

前端之家收集整理的这篇文章主要介绍了php – 检查数组是否不为空前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
********更新**********

var_dump:string(0)“”

我正在尝试检查数组的一部分是否不为空,然后显示代码,但代码显示无论如何.

我试过!is_null!空.我不确定哪个应该是正确的,或者我应该去:
if(sizeof($book [‘Booking’] [‘comments’])> 0)

码:

  1. <?PHP if (!empty($book['Booking']['comments'])) {?>
  2. <table width="100%" border="0">
  3. <tbody>
  4. <tr>
  5. <td style="font-family:'Lucida Grande',sans-serif;font-size:12px;font-weight:normal;color:#666666;">
  6. <?=$book['Booking']['comments']?>
  7. </td>
  8. </tr>
  9. </tbody>
  10. </table>
  11. <? } ?>

阵:

  1. Array
  2. (
  3. [Booking] => Array
  4. (
  5. [id] => 109
  6. [user_id] => 1
  7. [corporate_account_id] => 0
  8. [id_ref] => RES000109
  9. [price] => 178.00
  10. [arrival] => 2011-10-18 00:00:00
  11. [departure] => 2011-10-19 00:00:00
  12. [rate_title] =>
  13. [adult_guests] => 4
  14. [child_guests] => 0
  15. [company] => gravitate
  16. [titlename] =>
  17. [firstname] => SEOn
  18. [surname] => Gleeson
  19. [address1] => 8 Crow St
  20. [address2] =>
  21. [city] => Dublin
  22. [state] => Co. Dublin
  23. [postcode] => 2
  24. [country] => Ireland
  25. [phone] => 0863269087
  26. [mobile] =>
  27. [fax] =>
  28. [email] => ger@res360.com
  29. [comments] =>
  30. [created] => 2011-10-18 13:40:47
  31. [updated] => 2011-10-18 13:40:47
  32. [status] => 1
  33. [cancelled] => 0
  34. [request_src] => website
  35. [request_token] => 0
  36. [token] => ayzrGnx
  37. [survey_sent] => 0000-00-00 00:00:00
  38. [survey_returned] => 0000-00-00 00:00:00
  39. [send_sms] => 0
  40. [payment_time] => 0000-00-00 00:00:00
  41. [fullname] => SEOn Gleeson
  42. )
我怀疑它可能包含(bool)FALSE,这对于is_null()是不正确的.

尝试简单地:

  1. if ($book['Booking']['comments']) {

这也适用于评估为FALSE的任何内容,如空字符串.

猜你在找的PHP相关文章