Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi Guys,
I am having trouble populating a array variable with in a PHP class with the right values
I have a simple classCode: Select all
class tasl {
var $_ip_address;
var $_ports;
function tasl ()
{
$this->$_ip_address = array();
$this->$_ports = array();
}
with functions to add IP and ports submitted from a HTML form
function add_ip_address($ip)
{
$array_list = split (',',$ip);
foreach ($array_list as $ip1 => $value)
{
if(valid_ip_format($array_list[$ip1]))
{
array_push($this->$_ip_address,$array_list[$ip1]);
}When I populate the arrays and try to print them
the result is a combination of both the arrays in a single array
for e.g. if IP = 1.1.1.1, 2.2.2.2
and port = 35,34
the result is
Code: Select all
print_r($this->$_ip_address);
Array ( [0] => 1.1.1.1 [1] => 2.2.2.2 [2] => 34 [3] => 35 )
print_r($this->$_ports);
Array ( [0] => 1.1.1.1 [1] => 2.2.2.2 [2] => 34 [3] => 35 )whereas I was expecting them to b in different arrays...
Can some1 point towards what i am doing wrong?
Thanks
rev
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]