********更新**********
var_dump:string(0)“”
我正在尝试检查数组的一部分是否不为空,然后显示代码,但代码显示无论如何.
我试过!is_null!空.我不确定哪个应该是正确的,或者我应该去:
if(sizeof($book [‘Booking’] [‘comments’])> 0)
码:
- <?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的任何内容,如空字符串.