Array length: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
(reformatted as a draft task and adding proper headings, moving the see also section up and not making that a heading.)
Line 1: Line 1:
{{draft task}}
Determine the amount of elements in an array.
Determine the amount of elements in an array.
<br>As an example use an array holding the strings 'apple' and 'orange'.


;See also:
== JavaScript ==
* [[String length]]

=={{header|JavaScript}}==


<lang javascript>console.log(['apple', 'orange'].length);</lang>
<lang javascript>console.log(['apple', 'orange'].length);</lang>


== PHP ==
=={{header|PHP}}==


<lang php>print count(['apple', 'orange']); // Returns 2</lang>
<lang php>print count(['apple', 'orange']); // Returns 2</lang>


== SQL ==
=={{header|SQL}}==


<lang sql>SELECT COUNT() FROM (VALUES ('apple'),('orange'));</lang>
<lang sql>SELECT COUNT() FROM (VALUES ('apple'),('orange'));</lang>

== See also ==

* [[String length]]

Revision as of 08:01, 27 September 2015

Array length is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Determine the amount of elements in an array.
As an example use an array holding the strings 'apple' and 'orange'.

See also

JavaScript

<lang javascript>console.log(['apple', 'orange'].length);</lang>

PHP

<lang php>print count(['apple', 'orange']); // Returns 2</lang>

SQL

<lang sql>SELECT COUNT() FROM (VALUES ('apple'),('orange'));</lang>