Page 1 of 1

Looping Key=>value into an array

Posted: Sat Apr 30, 2005 4:33 pm
by icarpenter
Hi

Can anyone help I am trying to loop some values into an array with no success... can anyone help?

I am trying to create...

Code: Select all

$myarray = array( "key1"=>"value1",
                 "key2"=>"value2",
		         "key3"=>"value3",
	             "key4"=>"value4");
But by using a loop to insert the Key=>value information 1 at a time...

If anyone has any ideas i would be most greatful...

Thanks Ian

Looping Key=>value into an array

Posted: Sat Apr 30, 2005 5:31 pm
by icarpenter
It's OK if found the answer by using the following...

Code: Select all

$this->myarray["$key"] = $value;
Rgds Ian