note 99384 added to language.operators.type
| From: | mauritsdajong at gmail dot com | Date: | Fri, 13 Aug 2010 22:38:06 +0000 |
| Subject: | note 99384 added to language.operators.type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171665@lists.php.net to get a copy of this message | ||
Sometimes you want to typehint objects INSIDE an array, but I think you can't.
Instead, you can use this function to check the classes inside this array:
<?php
public checkObjectsArray(array $array, $classname, $strict = false) {
if (!$strict) {
foreach ($array as $element) {
if (!($element instanceof $classname)) {
return false;
}
}
}
else {
foreach ($array as $element) {
if (get_class($element) != $classname) {
return false;
}
}
}
return true;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 77.251.3.53
----
Manual Page -- http://www.php.net/manual/en/language.operators.type.php
Edit -- https://master.php.net/note/edit/99384
Del: integrated -- https://master.php.net/note/delete/99384/integrated
Del: useless -- https://master.php.net/note/delete/99384/useless
Del: bad code -- https://master.php.net/note/delete/99384/bad+code
Del: spam -- https://master.php.net/note/delete/99384/spam
Del: non-english -- https://master.php.net/note/delete/99384/non-english
Del: in docs -- https://master.php.net/note/delete/99384/in+docs
Del: other reasons-- https://master.php.net/note/delete/99384
Reject -- https://master.php.net/note/reject/99384
Search -- https://master.php.net/manage/user-notes.php