This shows you the differences between two versions of the page.
uphp:functions:sizeof [2017/04/12 13:02] jeff |
uphp:functions:sizeof [2021/09/13 05:57] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======sizeof====== | ||
- | |||
- | < | ||
- | |||
- | Return the number of elements in an < | ||
- | |||
- | ====Description==== | ||
- | |||
- | <well size=" | ||
- | < | ||
- | <span style=" | ||
- | <span style=" | ||
- | </ | ||
- | [[sizeof]] ( | ||
- | < | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | </ | ||
- | </ | ||
- | |||
- | ====Parameter==== | ||
- | |||
- | < | ||
- | |||
- | ====Return Value==== | ||
- | |||
- | < | ||
- | |||
- | ====Examples==== | ||
- | |||
- | <code php> | ||
- | <? | ||
- | |||
- | $array1[0]=1; | ||
- | $array1[1]=3; | ||
- | $array1[2]=5; | ||
- | print(sizeof($array1)); | ||
- | | ||
- | $array2[0]=7; | ||
- | $array2[5]=9; | ||
- | $array2[10]=11; | ||
- | print(sizeof($array2)); | ||
- | | ||
- | $array3=array(); | ||
- | print(sizeof($array3)); | ||
- | | ||
- | $array3=indexed_array(1, | ||
- | print(sizeof($array3)); | ||
- | | ||
- | $array4=array(1, | ||
- | $array5=array(" | ||
- | print(sizeof($array5)); | ||
- | |||
- | $s=" | ||
- | print(sizeof($s)); | ||
- | | ||
- | print(sizeof($undefined)); | ||
- | | ||
- | ?> | ||
- | </ | ||
- | |||
- | ====Notes==== | ||
- | |||
- | Array indexes are 0-based, but the count of the number of elements in an array is 1-based. Furthermore, | ||
- | |||
- | This is the uPHP version of the PHP function '' | ||
- | |||
- | Multidimensional arrays are not counted recursively, | ||
- | |||
- | As can be seen from the examples, uPHP always returns 0 for objects which are not arrays (mainline PHP will return 1 in some cases). If you are not certain the object is an < | ||
- | |||
- | ====See Also==== | ||
- | |||
- | [[array()]] - Create an < | ||
- | |||
- | [[array_key()]] - Return the key for an < | ||
- | |||
- | [[array_keys()]] - Return keys for an < | ||
- | |||
- | [[explode()]] - < | ||
- | |||
- | [[implode()]] - < | ||
- | |||
- | [[indexed_array()]] - Create an < | ||
- | |||
- | [[is_array()]] - Check if a variable is an < | ||
- | |||
- | [[json_encode()]] - < | ||
- | |||
- | [[print_r()]] - Dump the contents of an < | ||
- | |||
- | [[uphp: | ||