I thought more examples might be useful someone.
$name = ".$obj->$name."\n");
}
while (list($k,$v) = each($obj)) {
print("foo->$k = ".$v."\n");
}
foreach ($obj as $k => $v) {
print("foo->$k = ".$v."\n");
}
foreach ($obj as $k => $v) {
print("foo->$k = ".$obj->$k."\n");
}
?>
Regards,
--
Y
You can use get_class_vars() or get_object_vars()
http://www.php.net/manual/en/function.get-object-vars.php
http://www.php.net/manual/en/function.get-class-vars.php
You also need to use Variable variables (i.e. $$var) to iterate object
properties.
v1 = ".$bar->$name."\n");
}
?>
Regards,
--
Ya
Javascript has this very neat control structure that makes it easy to
iterate over the properties of an object. It would be nice to see something
similiar in PHP. I often use Objects as a way of "packing" data in a more
orderly fashion, and sometimes I need to do stuff to all the properties of
an
3 matches
Mail list logo