Tag: Sizeof

Sizeof

March 20, 2011 | Filed Under Array Functions, PHP Tutorial | Comments Off

syntax: int sizeof( mixed var [, int mode] )

sizeof — sizeof elements in an array

This function is an alias of count().

Description:

Code:


 $a[0] = 2;
$a[1] = 4;
$a[2] = 6;
echo $result = sizeof($a);
$b[0] = 6;
$b[5]  = 8;
$b[10] = 11;
echo $result = sizeof($b);/
// $result == 3
echo $result = sizeof(null);
//  $result == 0
echo $result = sizeof(true);
// $result == 1

Explanation:

This example shows sizeof() in use on an array .

Article written by admin

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker