PHP从array->值获取值

时间:2014-04-18 09:39:39

标签: php

我有这段代码:

function factuur_get_cardetails($form, &$form_state) {
        //dd('getting cardetails');
        $commands = array();
        $i = 0;
        foreach ($form_state['values']['field_invoice_line_deukendokter']['und'] as $line) {
            if (count($line) > 1) {
                // car
                //dd($line);

                // veld uitlezen
                $kenteken = $line['field_invoice_carlicensenumber']['und'][0]['value'];
                //dd($kenteken);
                $url = 'https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT?$filter=Kenteken%20eq%20%27'."$kenteken".'%27';
                $xml =  simplexml_load_file($url);
                foreach($xml->entry as $entry){
                    $properties = $entry->content->children('http://schemas.microsoft.com/ado/2007/08/dataservices/metadata');
                    $auto = $properties->properties->children('http://schemas.microsoft.com/ado/2007/08/dataservices');
                    dd($auto->Handelsbenaming[0]);
                    $model = 'field_invoice_line_deukendokter[und]['.$i.'][field_invoice_carmodel][und][0][value]';
                    $id = "input[name='".$model."']";
                    $commands[] = ajax_command_invoke($id, 'val', array($auto->Handelsbenaming));
                }
            }
            $i+=1;
        }

        return array('#type' => 'ajax', '#commands' => $commands);
    }

问题是当它使用

时它在我的文本框中返回[Object object]
$commands[] = ajax_command_invoke($id, 'val', array($auto->Handelsbenaming));

当我使用dd($ auto)创建日志时,我得到了这个

SimpleXMLElement Object
(
    [Brandstofverbruikbuitenweg] => 3.20
    [Brandstofverbruikgecombineerd] => 3.60
    [Brandstofverbruikstad] => 4.30
    [Catalogusprijs] => 20916
    [Cilinderinhoud] => 1560
    [CO2uitstootgecombineerd] => 95
    [Datumaanvangtenaamstelling] => 2011-07-19T00:00:00
    [DatumeersteafgifteNederland] => 2011-07-19T00:00:00
    [Datumeerstetoelating] => 2011-07-19T00:00:00
    [Eerstekleur] => GRIJS
    [G3installatie] => N.v.t.
    [Handelsbenaming] => DS3
)

所以它在某种程度上并没有给我带来价值" Handelsbenaming"而且我不知道为什么。 有没有人有想法?

当我制作一个日志dd($ auto-> Handelsbenaming); 它给了我这个

SimpleXMLElement Object
(
    [0] => DS3
)

但在我的文本框中它显示[Object object]而不是DS3

0 个答案:

没有答案