1

I want to use a new variable in a view using global PHP. Between the available variables, I have $row->my_field, and I want to put its value in a new variable.

$new = $row->my_field;
echo $new

I'm using this code in Output Code. I get the following error:

Syntax error, unexpected 'echo' (T_ECHO) ...

I cannot even use array_unique().

Is it possible to add a new variable? and Is it possible to use a function like array_unique()?

0

Is it possible to add a new variable?

YES

enter image description here

Is it possible to use a function like array_unique()?

Yes, as long as you have an array to pass as a parameter.

PS: You shouldn't be using Views PHP to begin with; you should create a template file for your view and add the PHP code there.

What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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