Re: [PHP] Printing a PHP Class From: 1LT John W. Holmes (holmes072000 <email protected>)
Date: 07/31/02

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...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php