Re: Printing a PHP Class
| From: | 1LT John W. Holmes | Date: | Wed, 31 Jul 2002 20:41:40 +0000 |
| Subject: | Re: Printing a PHP Class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110581@lists.php.net to get a copy of this message | ||
Maybe code will help...
> My problem is:
> when printing the Class Variables using the "standard" approach:
> =========
> function print_vars($obj) {
> $arr = get_object_vars($obj);
> while (list($prop, $val) = each($arr))
> {
> echo "$prop\t$val\n";
> }
> }
> =========
Try this:
function print_vars($obj)
{
$arr = get_object_vars($obj);
while (list($prop, $val) = each($arr))
{
if(is_array($val))
{ echo "$prop\t" . implode(",",$val) . "\n"; }
else
{ echo "$prop\t$val\n"; }
}
}
---John Holmes...