This example displays three user custom fields, fielda, fieldb and fieldc.  It uses the PHP function array_column() and therefore it does not need a foreach loop.

use Joomla\CMS\Factory;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
$customFields = FieldsHelper::getFields('com_users.user', Factory::getUser(), true);
$values = array_column($customFields, 'value', 'name');
// echo 'values = ' . print_r($values, true);
echo 'fielda = ' . $values['fielda'] . ' fieldb = ' . $values['fieldb'] . ' fieldc = ' . $values['fieldc'];