Re: arrays in a class

From: Date: Wed, 10 Oct 2001 15:34:44 +0000
Subject: Re: arrays in a class
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-70675@lists.php.net to get a copy of this message
class foo{ var $some_array; } $object = new foo; $object->some_array[0] = "bar"; echo $object->some_array[0]; -- Justin Garrett "L Melville" <lee@melville101.freeserve.co.uk> wrote in message news:20011010122051.32593.qmail@pb1.pair.com... > 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"); > > file://echos "Thomas" > > > > echo $arrayClass->GetElement("number"); > > file://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 > > > > > >

« previous php.general (#70675) next »