473,588 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ 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 2192

"René" <go****@teinze. com> wrote in message
news:56******** *************** ***@posting.goo gle.com...
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($subcla ss);
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
3192
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. I have even written a C++ book in which all programs are written with natural names. More information and free pages of the book can be found at http://www.naturalprogramming.com/cppbook.html I'm planning to produce similar books with the C#...
1
36378
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 about the allowed length for object names. Did I understand this correct: table names -> 128 characters (if ANSI characters)
5
4626
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 case. I figure that I need a query that will convert the first letter of a name to a capital letter. Another to convert any letter following a space to a capital. Another to convert any letter following an apostrophe (') to a capital and yet another...
0
2951
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 numbers in sequential order (1-55 when ran against iexplore.exe). When I open up iexplore.exe in Visual Studio, I see 23 icons. Each icon has 1 or more sizes of the icon...I'm assuming that there are, in fact, 55 icon resources in iexplore.exe,...
7
2117
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 function names from the file, so the functions can be executed in the order the function names are stored in a file. While trying to read the names from the file I am getting always "strings" and I am not able to execute them. I would like to...
20
27749
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 getting 'l_Fred_my_ins' out of the following. .... My_cls l_Fred_my_ins = new My_cls();
3
4516
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 following: FileStream.c
16
2586
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 previous python experiences: magic names (I felt almost as sad as when I discovered the strange pink worms that eat you in nethack, not to mention the mind flayers - I really hate them). I guess all programming languages have magic names to some...
4
3007
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 one disturbed by this. Somehow, an author publishing on the web, with no control over which user agents will access his page, has to avoid clashes with the union of all names deemed special by all those user agents, now and in the future? I...
0
7927
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8220
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7981
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8222
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6632
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5723
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3846
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.