查找多值字段的长度 [英] finding length of multi-value field

查看:121
本文介绍了查找多值字段的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在drupal节点中有一个多值cck字段。该字段称为 field_multip 。我需要知道这个字段中的项目数量,例如下面的例子3中的



我会以为 length 会做这个伎俩,但是$ code> $ node-> field_multip.length 也不是$ code $ $ node-> field_multip.length() code>为我工作。

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


解决方案

你想使用 count()

  $ itemcount = count $节点 - > field_multip); 

应该这样做。


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.

这篇关于查找多值字段的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆