note 95394 added to ref.var
| From: | distantimage24 at gmail dot com | Date: | Thu, 31 Dec 2009 04:31:44 +0000 |
| Subject: | note 95394 added to ref.var | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164484@lists.php.net to get a copy of this message | ||
that function of yours could be shortened by a couple lines;
<?
function ReduceVar ($Value) {
switch (gettype($Value)) {
case "boolean":
case "integer":
case "double":
case "string":
case "NULL":
return $Value;
case "resource":
return get_resource_type($Value);
case "object":
return ReduceVar(get_object_vars($Value));
case "array":
if (count($Value) > 0)
return ReduceVar(reset($Value));
default:
return NULL;
}
}
?>
produces the exact same result. but without the extra else case for the "array" type,
though this relies on the fact there is no break statement and thus it drops into the
"default" case, any updates for more cases could cause the other two lines to come back or
for that to be left right above the default case
----
Server IP: 192.41.40.227
Probable Submitter: 97.127.230.196
----
Manual Page -- http://www.php.net/manual/en/ref.var.php
Edit -- https://master.php.net/note/edit/95394
Del: integrated -- https://master.php.net/note/delete/95394/integrated
Del: useless -- https://master.php.net/note/delete/95394/useless
Del: bad code -- https://master.php.net/note/delete/95394/bad+code
Del: spam -- https://master.php.net/note/delete/95394/spam
Del: non-english -- https://master.php.net/note/delete/95394/non-english
Del: in docs -- https://master.php.net/note/delete/95394/in+docs
Del: other reasons-- https://master.php.net/note/delete/95394
Reject -- https://master.php.net/note/reject/95394
Search -- https://master.php.net/manage/user-notes.php