Syntax

PHP Count Items Syntax

In PHP, count items: counts array elements — count($nums)

Quick Answer

Syntax
count($nums)
PHPSyntax

Count Items

Code example
count($nums)

Counts array elements.

Learn More

How to count items in PHP

  1. Open your PHP file or editor.
  2. Copy the example, then replace its sample names and values for your code.

PHP Count Items Syntax

Use count($nums).

Related Syntax References

Frequently asked questions

What is the PHP syntax for count items?

Use this pattern: count($nums)

Can I copy this PHP code example?

Yes. Use Copy code and adapt the example to your program.

Is this PHP syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify