Re: Problems with Arrays and print and echo

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

 



Michael Felt 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]
6:10000003/20000044/8-TFDX
init $this->Xame[5] = B-E3KQ B-E3KQ Array[5]
5:10000003/20000044/B-E3KQ
init $this->Xame[4] = BR-6XP BR-6XP Array[4]
4:10000003/20000044/BR-6XP
init $this->Xame[3] = G5ED-Y G5ED-Y Array[3]
3:10000003/20000044/G5ED-Y
init $this->Xame[2] = O-LR1H O-LR1H Array[2]
2:10000003/20000044/O-LR1H
init $this->Xame[1] = UL-4ZW UL-4ZW Array[1]
1:10000003/20000044/UL-4ZW
init $this->Xame[0] = Y5J-EU Y5J-EU Array[0]
0:10000003/20000044/Y5J-EU
++++++++++++++++++++++++++++++++++++++++++++++
Thanks for your ideas, help, etc..

Maybe it is somethign as simple as "can't do that with echo", but when the arrays are all single element ( foo_array[0] is only element ) all statements work as expected.

regards,
Michael
 From - Fri
Anyone?

--
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