Hi,
I found the problem was not with array_keys. It was a place where I am pushing the values in a list.
list($level[$xml_elem['level']],$extra) = $temp[0];
The elements are overwritten in a list. I had tried to use add some values to my key and achieve a unqiue key value. But, while fetching the children of the key, I am having problems.
This is the code
$data = fread($fp, filesize($file));
fclose($fp);
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
$para = array();
$params = array();
$level = array();
$i=0;
foreach ($vals as $xml_elem)
{
if ($xml_elem['type'] == 'open')
{
if (array_key_exists('attributes',$xml_elem))
{
$temp=array_values($xml_elem['attributes']);
$temp[0]+=$i;
$i++;
list($level[$xml_elem['level']],$extra) = $temp[0];
} else
{
$level[$xml_elem['level']] = $xml_elem['tag'];
}
}
if ($xml_elem['type'] == 'complete') {
$start_level = 1;
$php_stmt = '$para';
while($start_level < $xml_elem['level']) {
$php_stmt .= '[$level['.$start_level.']]';
$start_level++;
}
$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
eval($php_stmt);
}
}
I have added value of "i" to my key. But I need to subtract this value to get the key's children. Please help me at which place I would be subtracting the "i" value.