获取关联数组的长度

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取关联数组的长度相关的知识,希望对你有一定的参考价值。

  1. /**
  2.  * Returns the length of an associative array or object similar function to Array.length
  3.  *
  4.  * @param $obj
  5.  * @return int
  6.  *
  7.  */
  8. public static function __getAssociativeArraySize($obj:Object):int {
  9. var length:int = 0; /* the length counter to be returned */
  10. if ($obj != {} || $obj != null) { /* check if the object is null or has no elements and return zero as the length */
  11. for (var s:String in $obj) { /* iterate on each element of the object and increase the counter */
  12. length++;
  13. }
  14. }
  15.  
  16. return length; /* return the length*/
  17. }

以上是关于获取关联数组的长度的主要内容,如果未能解决你的问题,请参考以下文章