Count Elements Of Array Without Using Any Function

Counting the elements in an array without using any method is quite simple. We just need to write the core php code to complete this task. If you are good in string manipulation of php then you will easily understand what i’m going to do.
First we will make an array which we will count without using the function. It look like that

Array

<?php
$abc = array(
23,
99,
'5'=>NULL,
carry,
'surname'=>john,
'4'=>america,
'202'=>washington,
"",
);
?>

This is our array and if you use any function to count it. It will off course give you the answer eight. But we are going to get this answer without using any function. We will just run a for-each loop to count this array. Here is my little code and logic.

Counts Element Without Function

<?php
foreach ($abc as $abc)
{
$b = $b + 1;
}
echo $b;
?>

This is how it works. There is no any big and giant logic behind this just a simple code to write and get the answer. For-each will run until the last element it get. And we just make a variable and increment it finally we will get the answer.