note 32713 deleted from function.count by didou
| From: | didou@php.net | Date: | Wed, 15 Oct 2003 17:31:45 +0000 |
| Subject: | note 32713 deleted from function.count by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58655@lists.php.net to get a copy of this message | ||
Note Submitter:
----
in response to joshua dot patterson a+ plexus dot com above this, instead of using:
//////////////////////////////
$tCount = count($array);
for ($i=0;$i<$tCount;$i++)
{
Some Code
if ($someVar==4)
{
array_splice($array,$i,1);
$tCount--;
}
}
/////////////////////////////////
try using foreach as follows:
foreach($Array)
//this steps through each value that an array has in it.
{
Some Code
}
or even:
foreach($Array as $Key => $Value)
//$Key is equal to the array key number and $Value is
//equal to the value at $Key.
{
Some Code
}
im unsure of how it works with multi dimensional arrays or if it is faster but i would think it is.