note 58667 modified in function.arrayiterator-valid by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 22:40:35 +0000 |
| Subject: | note 58667 modified in function.arrayiterator-valid by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147370@lists.php.net to get a copy of this message | ||
Sometimes you need to search through the array.
Here is my object-orientated Version:
<?php
class MyArrayIterator extends ArrayIterator
{
public function available($value)
{
if (in_array($value, (array)$this))
return true;
else
return false;
}
public function search($value)
{
foreach((array)$this as $Key => $values)
{
if ($values == $value)
return $Key;
}
return false;
}
}
?>
--was--
Sometimes you need to search through the array.
Here is my object-orientated Version:
class MyArrayIterator extends ArrayIterator
{
public function available($value)
{
if (in_array($value, (array)$this))
return true;
else
return false;
}
public function search($value)
{
foreach((array)$this as $Key => $values)
{
if ($values == $value)
return $Key;
}
return false;
}
}
http://php.net/manual/en/function.arrayiterator-valid.php