Hide Profile2 fields depending on it's value when viewing user profile
You'd be better off putting your code in a custom module, as you can implement hook_profile2_view() instead. That will give you far more control over the output.

Without more specifics it's hard to be accurate but generally speaking the code would look something like this:

function MYMODULE_profile2_view($profile, $view_mode, $langcode) {
  $field_items = field_get_items('profile2', $profile, 'field_name_of_field');
  if ($field_items) {
    $value = $field_items[0]['value'];

    if ($value == 'something') {
      $profile-&gt;content['field_name_of_field']['#access'] = FALSE;
    }
  }
}