Q:

How to access user languages inside GraphObject using Facebook PHP SDK v4

I queried the Facebook User Profile and get the Following response Facebook\GraphObject for Languages
Facebook\GraphObject Object
(
    [backingData:protected] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 106059522759137
                    [name] => English
                )

            [1] => stdClass Object
                (
                    [id] => 105673612800327
                    [name] => German
                )

            [2] => stdClass Object
                (
                    [id] => 106049856092338
                    [name] => Urdu
                )

        )

)

I am trying to access the property by following code but unable to get the array of languages:
$languages = $Usergraph->getProperty("languages");
$languages_array = array();

print_r($languages);

foreach ($languages as $language){
    $languages_array[] = $language->getProperty('name');
}

print_r($languages_array);

Is there any other way i can get the information of language

A:

Ok i Resolved that Issue after finding the information that i can cast my GraphObject as well.  So solution will be like this:
$languages = $Usergraph->getProperty("languages")->asArray();
$languages_array = array();
foreach ($languages as $language){
    $languages_array[] = $language->name;
}

print_r($languages_array);

and the Information will be displayed:
Array
(
    [0] => English
    [1] => German
    [2] => Urdu
)

