Dynamic data for distance in bricks

<?php 
/**
 ** in functions.php, custom hooks, or a snippets plugin
 ** add a function to return the distance
 ** that you want to output, change the function as need to
 ** output your formatted distance
 ** https://facetwp.com/help-center/facets/facet-types/proximity/#display-the-post-distance
 ** add to your bricks template as a dynamic data echo
 ** {echo: fwp_distance()}
 ** https://d.pr/i/gaXXUf
 ** https://academy.bricksbuilder.io/article/dynamic-data/#advanced
 **/

function fwp_distance() {

    $distance = facetwp_get_distance();
 
    // Round distance to 2 decimals and append ' mi'
    if ( false !== $distance ) {
        return round( $distance, 2 ) . ' mi';
    }

    return '';
}