Trouble extracting year from date field for computed field I have a date field, 'field_date', from which I need to extract the year.  The date format is yyyy-mm-dd, so I figured the following would do it:

$date = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_date')));
$year = explode("-", $date)[0];
$entity_field[0]['value'] = $year;


This gives me Parse error: syntax error, unexpected '[' Am I not getting the date string correctly?
Function array dereferencing was added in PHP 5.4, you must be using an older version.  

To fix:

$parts = explode("-", $date);
$year = $parts[0];