0

I am using Computed Field to concatenate a few text fields into one value. The text fields are pieces of a street address (the street address, the city, the state, and the zip code). When using the code below, I receive the error below.

COMPUTED CODE:

$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_address'))) . ', ' . array_pop(array_pop(field_get_items($entity_type, $entity, 'field_city'))) . ', ' . array_pop(array_pop(field_get_items($entity_type, $entity, 'field_state'))) . ' ' . array_pop(array_pop(field_get_items($entity_type, $entity, 'field_zip_code')));

DISPLAY CODE:

$display_output = $entity_field_item['value'];

ERROR:

Strict warning: Only variables should be passed by reference in eval() (line 1 of /home/mysite/public_html/sites/all/modules/computed_field/computed_field.module(468) : eval()'d code).

How can I resolve this issue?

1
$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_address')));

=>

$items = array_pop(field_get_items($entity_type, $entity, 'field_address'));
$entity_field[0]['value'] = array_pop($items);

You have to store result of function in variable and pass it to another function, instead of pass function to function.

Passing by Reference

Not the answer you're looking for? Browse other questions tagged or ask your own question.