Re: [PHP] generically accessing member variables problem

2002-11-06 Thread John Kenyon
Ok. I think I got it. Now I have to look at my code again to see if I can implement it. Thanks for your time. jck Maxim Maletsky wrote: Well, if, say, one class has this function: function inherit($class_name, $pointer) { $this->objects[$class_name] = $pointer; } then you end up knowing that

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread Maxim Maletsky
Well, if, say, one class has this function: function inherit($class_name, $pointer) { $this->objects[$class_name] = $pointer; } then you end up knowing that, whenever you need to access an instance for a class, you can use $this->objects['that_class']->that_array. What I picked on, was

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread John Kenyon
I am not really sure I understand what you are saying here, and I would like to. Let me first say that I think the syntax you came up with earlier will solve my immediate problem, but if I could design this in a better way I'd like to know. Let me give you a few more details: I have a large cla

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread Maxim Maletsky
You pass it the name of the element, and whatever the data inside. You do not need to add other sub-elements to it automatically, as you would need to be "searching" through the elements later for the right data. Whatever your need is - it's a good idea using arrays, and add other arrays into it.

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread John Kenyon
See below: MM> class Example { MM> var $array = array(); MM> function add2array($element_name, $val){ MM> $this->$array[$element_name] = $val; MM> } MM> } MM> $t = new Example(); $t->>add2array('array1',25); $t->>add2array('array2',26); $t->>add2array('array3',"Hello");

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread Maxim Maletsky
Tom Rogers <[EMAIL PROTECTED]> wrote... : > Hi, > > Thursday, November 7, 2002, 3:45:34 AM, you wrote: > > MM> Yet, this is not a such elegant way doing it. It can be helpful in a lot > MM> of cases, but most often, element key is enough. Try rethinking your > MM> logic: > > > MM> class Exam

Re[2]: [PHP] generically accessing member variables problem

2002-11-06 Thread Tom Rogers
Hi, Thursday, November 7, 2002, 3:45:34 AM, you wrote: MM> Yet, this is not a such elegant way doing it. It can be helpful in a lot MM> of cases, but most often, element key is enough. Try rethinking your MM> logic: MM> class Example { MM> var $array = array(); MM> function add

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread Maxim Maletsky
Tom Rogers <[EMAIL PROTECTED]> wrote... : > > Amazing what you learn on this list :) > This works: > > class Example > { >var $array1 = array(); >var $array2 = array(); >var $array3 = array(); > > function add2array($array_name,$val){ > $this->{"$array_name"}[] = $val; > }

Re[2]: [PHP] generically accessing member variables problem

2002-11-06 Thread Tom Rogers
Hi, Thursday, November 7, 2002, 3:11:12 AM, you wrote: MM> You can do: ${"this->>$passed_in_array_name"} MM> not sure right now of the correct syntaxing, I never do that - normally MM> I'd pass the element key. MM> -- MM> Maxim Maletsky MM> [EMAIL PROTECTED] MM> John Kenyon <[EMAIL PROTECTE

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread John Kenyon
Thanks, that may be what I was looking for. jck Maxim Maletsky wrote: You can do: ${"this->$passed_in_array_name"} not sure right now of the correct syntaxing, I never do that - normally I'd pass the element key. -- Maxim Maletsky [EMAIL PROTECTED] John Kenyon <[EMAIL PROTECTED]> wrote..

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread Maxim Maletsky
You can do: ${"this->$passed_in_array_name"} not sure right now of the correct syntaxing, I never do that - normally I'd pass the element key. -- Maxim Maletsky [EMAIL PROTECTED] John Kenyon <[EMAIL PROTECTED]> wrote... : > Thank you for replying, but I don't think I've made my problem clea

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread John Kenyon
Thank you for replying, but I don't think I've made my problem clear enough. Let me give it another shot. What I want is a function that takes the name of an array as a parameter so that it can be popped into any class that has arrays in it and work without modification. The problem I am having

Re: [PHP] generically accessing member variables problem

2002-11-06 Thread Marek Kilimajer
If I understand you, you need to have a basic class with the one function and subclass it. Then you can reference the array as $this->$passed_in_array_name John Kenyon wrote: I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have

[PHP] generically accessing member variables problem

2002-11-05 Thread John Kenyon
I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have classes like: class Example { var $array1; var $array2; var $array3; etc. } and I want to have a function in that class that looks something like this: function do_