473,468 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get the names of all subobjects?

Hello,

My example:

$person->telnumber->value
$person->faxnumber->value
$person->???

The names of the objects "telnumber" and "faxnumber" (and further
possible subobjects) are not known for me.

How can I get the names of all subobjects of an object?

Thanks a lot.
René
Jul 16 '05 #1
2 2186

"René" <go****@teinze.com> wrote in message
news:56**************************@posting.google.c om...
Hello,

My example:

$person->telnumber->value
$person->faxnumber->value
$person->???

The names of the objects "telnumber" and "faxnumber" (and further
possible subobjects) are not known for me.

How can I get the names of all subobjects of an object?

Thanks a lot.
René
I reckon you're talking arrays here...(?)
You can then find both the keys and values of the array by doing this;

foreach ($person as $key => $value) {
echo "$key is $value \n";
}

I.e. if (by your examples) some keys and values are like this $person->telnumber->555-1515
$person->faxnumber->555-2121
$person->address->Big Street

The above code will echo the following:
telnumber is 555-1515
faxnumber is 555-2121
address is Big Street

Hope this was what you're looking for.

--
Børge Alvestad
aka BraveBrain
Jul 16 '05 #2
René wrote:
Hello,

My example:

$person->telnumber->value
$person->faxnumber->value
$person->???

The names of the objects "telnumber" and "faxnumber" (and further
possible subobjects) are not known for me.

How can I get the names of all subobjects of an object?

Thanks a lot.
René


If you use the function "get_class_vars", you can get a list of all the
properties of the class. Loop through each element of the resulting
array, and use the "is_object" function to determine if it's an object.

$class = new Classname();
$vars = get_class_vars($class);

while ( list($name, $val) = each($vars) ) {
if ( is_object($val) ) {
print $name . " is an object!\n";
// to reference the property directly - not sure in how
// many versions of PHP this works in
$subclass = $class->$name;
print_r($subclass);
print "\n";
}
}

Jason Dumler

Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kari Laitinen | last post by:
During the past 15 years I have been writing computer programs with so-called natural names, which means that the names (identifiers, symbols) in progarms are constructed of several natural words....
1
by: Jens Riedel | last post by:
Hello, we are planning to port an application from one database to different others, including DB2. While reading the GettingStarted document for DB2 Personal Edition I got a little confused...
5
by: dixie | last post by:
I have recently received data for a database where there are over 1000 people's names, all in capital letters (surnames and first names). I really need to be able to convert them all to lower...
0
by: Mythran | last post by:
I wrote some code that is supposed to enumerate through the specified file's win32 resources and return a string-array of all icon names. When it runs, it returns a string-array with a bunch of...
7
by: Petr Jakes | last post by:
I have got names of functions stored in the file. For the simplicity expect one row only with two function names: printFoo, printFOO In my code I would like to define functions and then to read...
20
by: Shawnk | last post by:
I would like to get the class INSTANCE name (not type name) of an 'object'. I can get the object (l_obj_ref.GetType()) and then get the (l_obj_typ.Name) for the class name. I there any way of...
3
by: cybernerdsx2 | last post by:
Hi, I notice a function prototype being declared as following: FileStream.h ========= extern void openFile(char *__ident, int __option); But, in the function declaration part shown as...
16
by: per9000 | last post by:
Hi, I recently started working a lot more in python than I have done in the past. And I discovered something that totally removed the pretty pink clouds of beautifulness that had surrounded my...
4
by: Steven Simpson | last post by:
Stefan Ram wrote (in "More than one language in a page"): Is this a new trend of user-agent writers (Microformats, and now Google) staking claims on the @class namespace? I'm surely not the only...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.