note 47769 modified in function.strlen by thiago
| From: | thiago@php.net | Date: | Wed, 11 Feb 2009 14:16:11 +0000 |
| Subject: | note 47769 modified in function.strlen by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150484@lists.php.net to get a copy of this message | ||
<?php
function array_strlen(&$array,$fuse=200,$depth=0)
{
// returns the strlen of all elements in a given array, an array inside
// an array will add another 8 points
// fuse: Recursion is limited to 200 calls, if you want unlimited calls
// use fuse=0 - warning: if an array element contains a reference
// to the array itself it will run endless if fuse set to 0 or below.
$strlen=0;
$fuse-=1;
if ($fuse==0) return $strlen;
if (is_array($array))
{
if ($depth>0) $strlen+=8;
reset($array);
$depth+=1;
foreach ($array as $sub) $strlen+=array_strlen($sub,$fuse,$depth);
}
else
{
$strlen+=strlen($array);
}
return $strlen;
} // array_strlen()
?>
--was--
function array_strlen(&$array,$fuse=200,$depth=0)
{
// returns the strlen of all elements in a given array, an array inside
// an array will add another 8 points
// fuse: Recursion is limited to 200 calls, if you want unlimited calls
// use fuse=0 - warning: if an array element contains a reference
// to the array itself it will run endless if fuse set to 0 or below.
$strlen=0;
$fuse-=1;
if ($fuse==0) return $strlen;
if (is_array($array))
{
if ($depth>0) $strlen+=8;
reset($array);
$depth+=1;
foreach ($array as $sub) $strlen+=array_strlen($sub,$fuse,$depth);
}
else
{
$strlen+=strlen($array);
}
return $strlen;
} // array_strlen()
http://php.net/manual/en/function.strlen.php