Page 1 of 1

Problem with array_keys

Posted: Sat Jun 26, 2004 4:17 am
by Mahesh
Hi,

I am parsing an xml file. I have stored the attributes of the XML file in an array. I am using array_keys to return key values from the array. This function returns only unique values. I have several repeatations of a key in the array, but array_keys fetches only unique values. Is there some other way I can get all the key values?

Please Help

Thanks
Mahesh

Posted: Sat Jun 26, 2004 4:25 am
by feyd
note how this works:

Code: Select all

<?php

	$test = array('test'=>1,'test'=>2,'test'=>3);
	
	print_r($test);
	
	print_r(array_keys($test));

?>
outputs

Code: Select all

Array
(
    &#1111;test] =&gt; 3
)
Array
(
    &#1111;0] =&gt; test
)

Problem with list

Posted: Sat Jun 26, 2004 4:43 am
by Mahesh
Sorry, the problem is becuase I had used a list to hold values which does not allow duplicate values. How can I enter duplicate values to list?

Posted: Sat Jun 26, 2004 10:03 am
by feyd
you could check for the existance of the key you are attempting to enter, and concatenate with an existing one..

Posted: Thu Jul 01, 2004 9:02 am
by Mahesh
Thank You for the suggestions. I managed it to achiveve it through another program :)