How to check condition and print a value using views-view-field--viewname.tpl.php? I'm having a view and I've created a template file for the row style output.
I'm able to access the fields using the below code:

$fields: An array of $field objects. Each one contains:
$field-&gt;content: The output of the field.
$field-&gt;raw: The raw data for the field, if it exists. This is NOT output safe.


I'm getting output for the below code:

&lt;?php print $fields['field_some_field_name']-&gt;content; ?&gt;


But when I'm trying to print the fields nothing is getting returned:

&lt;?php print_r($fields); ?&gt;


I'm also unable to check the condition for the fields:

&lt;?php if($fields['field_some_field_name']-&gt;content == 'Test') { } ?&gt;
I'm also unable to check the condition for the fields:

&lt;?php if($fields['field_some_field_name']-&gt;content == 'Test') { } ?&gt;



That is probably because in actuality:

$fields['field_some_field_name']-&gt;content = &lt;div&gt;Test&lt;/div&gt;

Therefore, &lt;div&gt;Test&lt;/div&gt; is not equal to Test

So what you could do is use raw instead, as raw has no html/markup around the value.

&lt;?php if($fields['field_some_field_name']-&gt;raw == 'Test') { } ?&gt;


else, you could still use content with the PHP striptags() function

&lt;?php if(striptags($fields['field_some_field_name']-&gt;content) == 'Test') { } ?&gt;


Or else, you could still use your original &lt;?php print $fields['field_some_field_name']-&gt;content; ?&gt; but as long as you strip all the markup added by views as shown in my answer to "Is there a more performant alternative than overriding template files?".