The Function:
<?php
function ListCount($list, $delimiter="")
{
if($delimiter == "")
{
$delimiter = ",";
}
$a = explode($delimiter,$list);
return count($a);
}
?>
Usage:
Using the ListCount function is simple.
<?php
$list = "a,b,c,d";
echo ListCount($list);
?>
The Result: 4
Or, you can declare a delimiter:
<?php
$list = "CATDOGMOUSEFOXHORSE";
echo ListCount($list);
?>
The Result: 5
1 comment:
I just stumbled upon your informative blog and wanted to say that I have really enjoyed reading your blog posts. I will be your frequent visitor.
Post a Comment