note 13018 modified in function.array by tularis

From: Date: Tue, 04 Feb 2003 18:39:18 +0000
Subject: note 13018 modified in function.array by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-43409@lists.php.net to get a copy of this message
[Editor's Note] Instead of using: $a[0]->$test1 = 1; $a[0]->$test2 = 1; $a[1]->$test1 = 2; $a[1]->$test2 = 2; you should use: $a[0]->test1 = 1; $a[0]->test2 = 1; $a[1]->test1 = 2; $a[1]->test2 = 2; since right now, you are doing this: $a[0]->$test1 = 1; //evals to: $a[0]-> = 1; [/Note] This is a small script that shows how to use an array of a Class. <? class test{ var $test1; var $test2; } $a = array(); $a[] = new test; $a[0]->$test1 = 1; $a[0]->$test2 = 1; $a[1]->$test1 = 2; $a[1]->$test2 = 2; $x = $a[0]->$test1; $y = $a[0]->$test2; echo "$x - $y"; ?> --was-- This is a small script that shows how to use an array of a Class. <? class test{ var $test1; var $test2; } $a = array(); $a[] = new test; $a[0]->$test1 = 1; $a[0]->$test2 = 1; $a[1]->$test1 = 2; $a[1]->$test2 = 2; $x = $a[0]->$test1; $y = $a[0]->$test2; echo "$x - $y"; ?> http://www.php.net/manual/en/function.array.php

« previous php.notes (#43409) next »