如何从数据数组中获取特定值? [关闭]

I am trying to fetch specific data from the array of data but not able to get proper output. Please guide me.

Code

echo "<pre>";
    $cart = VirtueMartCart::getCart();
    $cmpny=$cart->BT;
    print_r($cmpny);

    $i=0;
    foreach($cmpny as $data)
    {
        if(true)
        {
        echo $data."
";
        }
        $i++;

    }
    exit;   

Output What I am Getting

Output What I am Getting

How could i able to fetch only [company] or only any single element.... i had try to access with

 $data->company

but not able to fetch.... so please guide me....

Hello Please try this

foreach($cmpny as $data)
{          
   echo $data['company']."
";
}

I think you got result as company data

You have array as result, so you should use array access instead of property access: $data['company']

$data->company can only be used if the $data is an object, to access elements in array, you should use $data['company']