Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Assigning values to dynamic array


Message #1 by "arun" <arun@l...> on Wed, 24 Jul 2002 18:46:24 +0530
Christopher Scollo wrote:

>If $Title is a string, then you should use the concatenation operator (.), not the addition operator (+).  This ain't
JavaScript. :)
>
>Or just use assignment, if you don't mean to concatenate:
>
>$this->Titles[$ColumnIndex] = $Title;
>
>
>On Wed, 24 Jul 2002, arun wrote:
>
>>Hi,
>>
>>When i try to assign value to the array it is not working. I want to know
>>whether this is the way to assign values to an array.
>>
>>
>>class Table
>>{
>>        var $Titles = array();
>>        var $Data = array();
>>
>>        function SetTitle($Title, $ColumnIndex)
>>        {
>>                $this->Titles[$ColumnIndex] += $Title;
>>        }
>>
>>        function SetData($RowIndex, $ColumnIndex, $Value)
>>        {
>>                $this->Data[$RowIndex][$ColumnIndex] += $Value;
>>        }
>>
>>};
>>
>>It assigns '0' for all. If i try using :
>>                $this->Data[$RowIndex][$ColumnIndex] += $Value;
>>
>>It assigns null for all. If i try using :
>>                $this->Data[$RowIndex][$ColumnIndex] = $Value;
>>
>>
>>
>>with regards,
>>arun
>>
>>
>>
>>
>
>
>
you can also use the .= concatenation shorthand.



  Return to Index