How to get the length of an array (number of elements) in php

WBOY
Release: 2016-07-25 08:55:52
Original
1094 people have browsed it
  1. $users = array ("qdv.cn", "haotu.net", "sharejs.com", "google.com");
  2. print count($users)-1;
Copy code

Example 2, usage of php function count to get the length of an array.

Example 2, the count function is used to obtain the length of the array

  1. $array = array("PHP", "Perl", "Java");
  2. print_r("Size 1: ".count($array)."n");
  3. $array = array();
  4. print_r("Size 2: ".count($array)."n");
  5. ?>
Copy code

Output result: Size 1: 3 Size 2: 0



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template