Re: [PHP] array's
now it works, thx alot :) regards patrick Jason Wong [EMAIL PROTECTED] skrev i meddelandet [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Sunday 18 August 2002 12:25, Pafo wrote: anyone that can find the problem..? description below. function PrintInfo() { for ($this-i = 0; $this-i count($this-RelicName); $this-i++) { print $this-RelicName[$this-i] : $this-RelicType[$this-i] : $this-RelicRealm[$this-i] : $this-RelicOwner[$this-i]br; } } Not sure why you're defining your counter as $this-i. I would just use $i. Your problem is that inside double quotes the expression: $this-RelicName[$this-i] is ambiguous. In this case what the interpreter has done is to print $this-RelicName, which is an array, so your output contains 'Array'. It then prints a literal bracket '[', then the value of $this-i, then another literal bracket ']', and thus that is what you see. To remove the ambiguity to need to state exactly what you mean and enclose your expression in {} : print {$this-RelicName[$this-i]} ... the function PrintInfo prints out this: '***' OUTPUT '**' Array[0] : Array[0] : Array[0] : Array[0] Array[1] : Array[1] : Array[1] : Array[1] Array[2] : Array[2] : Array[2] : Array[2] heh,, not exacly what i wanted :/ -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Argue for your limitations, and sure enough, they're yours. -- Messiah's Handbook : Reminders for the Advanced Soul */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array's
anyone that can find the problem..? description below. html head titledebug/title /head body '***' OUTPUT '**'brbr ?php class Relic { var $RelicName = Array(); var $RelicType = Array(); var $RelicRealm = Array(); var $RelicOwner = Array(); var $i; function PrintInfo() { for ($this-i = 0; $this-i count($this-RelicName); $this-i++) { print $this-RelicName[$this-i] : $this-RelicType[$this-i] : $this-RelicRealm[$this-i] : $this-RelicOwner[$this-i]br; } } function SetName($name) { $this-RelicName[] = $name; } function SetType($type) { $this-RelicType[] = $type; } function SetRealm($realm) { $this-RelicRealm[] = $realm; } function SetRelicOwner($owner) { $this-RelicOwner[] = $owner; } } $temp = new Relic(); $temp-SetName(olle); $temp-SetType(melee); $temp-SetRealm(Hibernia); $temp-SetRelicOwner(Albion); $temp-SetName(bertil); $temp-SetType(melee); $temp-SetRealm(Albion); $temp-SetRelicOwner(Hibernia); $temp-SetName(sture); $temp-SetType(magic); $temp-SetRealm(Midgard); $temp-SetRelicOwner(Midgard); $temp-PrintInfo(); ? /body /html the function PrintInfo prints out this: '***' OUTPUT '**' Array[0] : Array[0] : Array[0] : Array[0] Array[1] : Array[1] : Array[1] : Array[1] Array[2] : Array[2] : Array[2] : Array[2] heh,, not exacly what i wanted :/ regards patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array's
On Sunday 18 August 2002 12:25, Pafo wrote: anyone that can find the problem..? description below. function PrintInfo() { for ($this-i = 0; $this-i count($this-RelicName); $this-i++) { print $this-RelicName[$this-i] : $this-RelicType[$this-i] : $this-RelicRealm[$this-i] : $this-RelicOwner[$this-i]br; } } Not sure why you're defining your counter as $this-i. I would just use $i. Your problem is that inside double quotes the expression: $this-RelicName[$this-i] is ambiguous. In this case what the interpreter has done is to print $this-RelicName, which is an array, so your output contains 'Array'. It then prints a literal bracket '[', then the value of $this-i, then another literal bracket ']', and thus that is what you see. To remove the ambiguity to need to state exactly what you mean and enclose your expression in {} : print {$this-RelicName[$this-i]} ... the function PrintInfo prints out this: '***' OUTPUT '**' Array[0] : Array[0] : Array[0] : Array[0] Array[1] : Array[1] : Array[1] : Array[1] Array[2] : Array[2] : Array[2] : Array[2] heh,, not exacly what i wanted :/ -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Argue for your limitations, and sure enough, they're yours. -- Messiah's Handbook : Reminders for the Advanced Soul */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP] array's
anyone that can find the problem..? description below. html head titledebug/title /head body '***' OUTPUT '**'brbr ?php class Relic { var $RelicName = Array(); var $RelicType = Array(); var $RelicRealm = Array(); var $RelicOwner = Array(); var $i; function PrintInfo() { for ($this-i = 0; $this-i count($this-RelicName); genereal question: would be for($i = 0; $ii count($this-RelicName) faster ? $this-i++) { print $this-RelicName[$this-i] : $this-RelicType[$this-i] : $this-RelicRealm[$this-i] : $this-RelicOwner[$this-i]br; } } echo $this-RelicName[$this-i]. : .$this-RelicType[$this-i]. : .$this-RelicRealm[$this- i].:$this-RelicOwner[$this-i].br; echo and print functions obviously don't get along with class variable in quotes. greetings robert function SetName($name) { $this-RelicName[] = $name; } function SetType($type) { $this-RelicType[] = $type; } function SetRealm($realm) { $this-RelicRealm[] = $realm; } function SetRelicOwner($owner) { $this-RelicOwner[] = $owner; } } $temp = new Relic(); $temp-SetName(olle); $temp-SetType(melee); $temp-SetRealm(Hibernia); $temp-SetRelicOwner(Albion); $temp-SetName(bertil); $temp-SetType(melee); $temp-SetRealm(Albion); $temp-SetRelicOwner(Hibernia); $temp-SetName(sture); $temp-SetType(magic); $temp-SetRealm(Midgard); $temp-SetRelicOwner(Midgard); $temp-PrintInfo(); ? /body /html the function PrintInfo prints out this: '***' OUTPUT '**' Array[0] : Array[0] : Array[0] : Array[0] Array[1] : Array[1] : Array[1] : Array[1] Array[2] : Array[2] : Array[2] : Array[2] heh,, not exacly what i wanted :/ regards patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array's
Please help! Im have been trying to get a multi-dimentional array for so time now and dont seems to get a right! I have the following : while($row=db_range()){ list($co_id,$surname,$init,$ba) = $row; $acid[$i] = array($a=array($co_id), $b=array($surname,$init), // does it work like this ??? $c=array($ba)) ; $i++; }//end while 1 I have 4 fields that i want to to put in an array and about 3000 records. How can i list the fields in an array and retrive the values out of the array PLS help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Array's in classes
Hi Guys, I have written a class in which it uses the global command to get the value of a variable from outside of this class which I use within the class. I have recently changed this variable to an array and added 5 extra keys to this array. It is a string indexed array. In now seems as though PHP wont import the array. It is really weird though because if I access the key of an array such as $database[hostname] is just echo's nothing at all to the browser. It also echo's nothing to the browser if I use $database[0]. But, if I echo just $database to the browser it returns Array ? Does anybody have any idea of why this is happening? Thanks Scott. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]