You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== length ==
Sizeable |- ! scope="row" | Throws | |- ! scope="row" | Since | 3.1.2 |- ! scope="row" | Restricted |
[[../../Optimizer#CACHE_RETURN|CACHE_RETURN]] |} === Usages ===
Copy Code
The output would be:
Copy Code
The output would be:
Returns the character length of str, if the value is castable to a string, or the length of the ms.lang.Sizeable object, if an array or other Sizeable object is given.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| length
|-
! scope="row" | Returns
| int
|-
! scope="row" | Usages
| str Sizeable |- ! scope="row" | Throws | |- ! scope="row" | Since | 3.1.2 |- ! scope="row" | Restricted |
No
|-
! scope="row" | Optimizations
| [[../../Optimizer#CONSTANT_OFFLINE|CONSTANT_OFFLINE]] [[../../Optimizer#CACHE_RETURN|CACHE_RETURN]] |} === Usages ===
length(str)
length(Sizeable)=== Examples === ====Example 1==== Strings Given the following code:
length('this is a string')
Copy Code1 {{function|length}}('this is a string')
:16====Example 2==== Arrays Given the following code:
length(array('1', 2, '3', 4))
Copy Code1 {{function|length}}({{function|array}}('1', 2, '3', 4))
:4
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)