Mike,
Yes, you can create and access an array within a class. I've written
seveal classes using arrays and it works just fine:
class Produce
{
var $Fruit = array();
function Produce()
{
// Access class variable
$this->Fruit[] = "Oranges";
$this->Fruit[] = "Grapes";
}
function More()
{
// Create and access local array
$Vegies = array();
$Vegies[] = "Broccoli";
$Vegies[] = "Onions";
}
}
Michael Sims wrote:
>
> At 03:04 PM 1/5/2002 -0800, Chris Hall wrote:
> >Just a quicky --
> >
> >I have yet to see anyone define an array within a class, yet if it is
> >possible, would i be able to access that array with
> >$this->array["variable"];?
>
> I've designed a class that has a method that RETURNS an array, but it
> sounds like you want to define one of the properties of your class as an
> array, i.e.:
>
> class testObject {
>
> var $testarray = array("firstindex" => "firstvalue",
> "secondindex" => "secondvalue");
>
> ...
>
> }
>
> I haven't personally done this, but I can't see why it wouldn't be
> possible. Then if you wanted to access it inside a method you should be
> able to the way you have described, like:
>
> function testMethod () {
>
> return $this->testarray["firstindex"];
> }
>
> Should work....why don't you give it a shot and see what happens? :)
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
Do you need a Web-based Content Publishing System ?
Call me for more details.
Ed Swartz
ColdFusion and PHP Development
978.772.0888
http://www.sandypondconsulting.com
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]