PHP - 对象转换为Array,现在需要一个Value

时间:2015-09-02 08:31:03

标签: php

我设法在这里迷惑自己,我有一个对象,我已经转换为数组,现在想得到的值:

echo var_dump((array)$obj['country_id']);

输出:

array(1) { [0]=> string(2) "GB" } 

我如何简单地获得“GB”?

1 个答案:

答案 0 :(得分:2)

试试这个:

treeViewItem.MouseDoubleClick += (sender, args) => {
   TextBlock tb = args.OriginalSource as TextBlock;
   if (tb == null) {
       return; 
   }
   else if (tb.DataContext is MyClass) {
       var myClass = tb.DataContext as MyClass;
       //Do something with myClass   
   }      
};