count array php
<?php
$arr = ["one", "two", "three", "four"];
echo count($arr);
?>// using count() we can get proper length of the array
$names = array("Ankur","Raj","Ram","Suresh");
// pass array into count() as parameter it will return array length
echo count($names);
// output : 4<?php
$cars=array("Volvo","BMW","Toyota");
echo count($cars);
?>count($myArray);<?php
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
var_dump(count($a));
$b[0] = 7;
$b[5] = 9;
$b[10] = 11;
var_dump(count($b));
var_dump(count(null));
var_dump(count(false));
?>
/* result
int(3)
int(3)
Warning: count(): Parameter must be an array or an object that implements Countable in … on line 12 // as of PHP 7.2
int(0)
Warning: count(): Parameter must be an array or an object that implements Countable in … on line 14 // as of PHP 7.2
int(1)
*/
Also in PHP:
- date time long format php
- base64 file php
- date in pphp
- check if string include char php
- create a directory in php if not exists
- php uppercase
- A random character from a string of characters:
- check if string container string phph
- create foreign key laravel migration
- debugger for php
- access PHP error log
- Laravel Eloquent, group by month/year
- cache clear in laravel by time
- WordPress Creating “startupl” folder and Wrtting to .htaccess
- codeigniter sql last insert id
- cakephp send mail bcc
- enable reporting php development mode
- basic code for file upload in php
- console.log php variable
- client ip php
- base 64 decode in php
- db connection in php
- artisan command for clearing cache
- Your Composer dependencies require the following PHP extensions to be installed: fileinfo