开发者

finding length of multi-value field

开发者 https://www.devze.com 2023-01-10 02:45 出处:网络
I have a multi-value cck field in a drupal node. The field is called field_multip. I need to know the number of items in this field, for example 3 in the case 开发者_运维技巧below

I have a multi-value cck field in a drupal node. The field is called field_multip. I need to know the number of items in this field, for example 3 in the case 开发者_运维技巧below

I would have thought that length would do the trick, but neither $node->field_multip.length nor $node->field_multip.length() worked for me.

field_multip
   [0] 
      [id]
      [sec]
   [1]
      [id]
      [sec]
   [2]
      [id]
      [sec]


You want to use count()

$itemcount = count($node->field_multip);

Should do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消