note 95394 deleted from ref.var by danbrown
| From: | danbrown@php.net | Date: | Thu, 31 Dec 2009 04:52:29 +0000 |
| Subject: | note 95394 deleted from ref.var by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164487@lists.php.net to get a copy of this message | ||
Note Submitter: distantimage24 at gmail dot com
----
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