Rendering field with the help of functions I have a field and I can render its value in a such way:

&lt;?php print $entity1-&gt;field_list_of_options['und'][0]['safe_value'];?&gt;


But I have many different entities at the page so I want to hide the following tail in a function in order to get something like this:

&lt;?php print $entity1-&gt;Get_list(); ?&gt;


How can I do it? I tried to get predefined functions in a custom module but couldn't find a proper hook. How can I handle this problem?

I wrote the following in order to collect my "tails":

function mymodulename_getText($entityId,$field){
    return $entityId-&gt;$field."['und'][0]['safe_value']";
}

And so, I use it in such way: 

&lt;?php 
$enityId = 2;
$entity2 = entity_load_single('entitytype', $entityId); ?&gt;
&lt;p&gt;&lt;?php print getText($entity2, field_list_of_options); ?&gt;&lt;/p&gt;

But I don't know how to implement my function to my custom module in order to get it in node's body where I want to print it using PHP Filter.
The correct syntax for your approach would be:

function mymodulename_getText($entityId,$field){
    return $entityId-&gt;$field['und'][0]['safe_value'];
}


I suggest to sanitize that with a isset().