Jump to content


Photo

array problem


  • Please log in to reply
2 replies to this topic

#1 vatzcar

vatzcar
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 11 August 2006 - 07:19 PM

hi,
i'm trying to get a class level two dimentional array which i can access from various function. the code i've done like this
class chain
	{
		var $tst;
                
                function test(){
			$j=0;
			for($i=0;$i<5;$i++){
				for($k=0;$k<5;$j++,$k++){
					$this->$tst[$i][$k] = $j;
				}
			}
			echo "<br>";
			$isize = sizeof($this->$tst);
			for($i=0;$i<$isize;$i++){
				$ksize = sizeof($this->$tst[$i]);
				for($k=0;$k<$ksize;$k++){
					echo $this->$tst[$i][$k];
				}
			}
		}
	}

now the sizeof is returning only 1 element which contains the last value. but i want all element with different value. function level local array is working fine, but i need class level.  any help will be great.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 11 August 2006 - 07:51 PM

Change you references to

$this->$tst

to

$this->tst
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 vatzcar

vatzcar
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 11 August 2006 - 08:01 PM

that is a great help from you. thank you so much.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users