Re: arrays in a class
| From: | L Melville | Date: | Wed, 10 Oct 2001 12:03:36 +0000 |
| Subject: | Re: arrays in a class | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70640@lists.php.net to get a copy of this message | ||
Thanks for the reply, is there a way of accessing the array directly, with
out using get/set methods?
ie;- would something like this work
$arrayClass = new AccessArray;
$arrayClass->m_myArray[2] = "blah";
lee
"Thomas Buck" <tom@localeyes-uk.com> wrote in message
news:5.1.0.14.0.20011010114326.00a8cae0@pop.steamradio.com...
> Hi,
>
> You don't go into much detail, but here's one method, I suppose (?)
>
> Class AccessArray {
> var m_myArray;
>
> function SetElement($name,$value) {
> $this->m_myArray[$name] = $value;
> }
>
> function GetElement($name) {
> return $this->m_myArray[$name];
> }
> }
>
> $arrayClass = new AccessArray;
> $arrayClass->SetElement("name","Thomas");
> $arrayClass->SetElement("number","123321);
>
> echo $arrayClass->GetElement("name");
> //echos "Thomas"
>
> echo $arrayClass->GetElement("number");
> //echos "123321"
>
> Thomas.
>
> >Hi,
> >
> >How can i set up and access arrays within a class? can anyone give a
> >quick example.
> >
> >thanks in advance
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-general-help@lists.php.net
> >To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>