将xml数据解析为php时,数组到字符串转换错误

I m new in PHP.When I try to store variable in array i got this error ** Array to string conversion ** PHP Code is :

$record = simplexml_load_file('demo.xml');
foreach ($record as $item):       
    $a=$item->item2->record->p21;   
    $b=$item->item2->record->bq_21; 
    echo $arr1 = array($a,$b); 
endforeach;

I wants value only ....If print_r is used then its gives this o/p

Array ( [0] => SimpleXMLElement Object ( [0] => 26 ) [1] => SimpleXMLElement Object ( [0] => 1 ) )

I want this only

26 1

Use print_r() instead of echo

print_r(array($a,$b));

You have to cast simpleXML Object to a string. (string)$a and (string)$b

$record = simplexml_load_file('demo.xml');
foreach ($record as $item):       
    $a=$item->item2->record->p21;   
    $b=$item->item2->record->bq_21; 
    $arr1 = array($a,$b);
    print_r($arr1);
endforeach;

var_dump (http://sg3.php.net/var_dump) should be used for debugging data in an object. Also print_r (http://us2.php.net/print_r) can be used that helps printing arrays.