Re: Problems with Arrays and print and echo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/7/06, Michael Felt <register@xxxxxxxxxxxxx> wrote:
> Slowly I am getting the output I want.
>
> Trying to use "dynamic" arrays, does creat the array I want, but getting
> the info is sometimes surprising.
>
> I notice a difference between arrays used locally in a function, and
> arrays used as a 'var' in a class function (all in PHP 4 atm).
>
> Code snippet:
>                  echo "ROWS returned are: $max\n";
>                  $this->count = $max;
>
>                  while ($max--) {
>                          $row = mysql_fetch_row($result);
>                          $this->name[$max] = sprintf("%s", $row[0]);
>                          $Name[$max] = sprintf("%s", $row[0]);
> echo "init \$this->Xame[$max] = $row[0]";
> echo " $Name[$max] $this->name[$max]\n";
>                          $regionID[$max] = $row[1];
>                          $constellationID[$max] = $row[2];
>                          $this->ID[$max] = $row[3];
> printf("%d:%d/%d/%s\n",$max,$regionID[$max],$constellationID[$max],
>                                 $this->name[$max]);
>                  }
> ================
> Line wrap is messing things up a bit.
> Was trying sprintf to see if the was a buffer problem coming from mysql.
> Problem seems to be the same, regardless.
> Also, the names changes ($this->name[] versus $Name[]) are deliberate,
> for just in case....
> ================
>
> Output (debuging):
> ROWS returned are: 7
> init $this->Xame[6] = 8-TFDX 8-TFDX Array[6]

Is the problem that you're getting array[6] instead of the value?
Explain what you see and what you expect to see.

What is var $name originally set to, ie:

var $name = array(); (or '' or ....) ?

--
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux