Dynamically display font icons in widget

This is more a PHP question from what I can gather, but hopefully this will help or at least get you on your way. I am making a few assumptions here, like you already have FontAwesome called and working in your site for example.

I am also not sure why you have 2x get_post_meta(); functions in a conditional statement with the same output for each condition – doesn’t make sense to me but I have included it the way you have it in the sample code below in any case.

You can try this, I have added comments so you can understand the logic:

<?php
global $wp_query;
$postid = $wp_query->post->ID;

if( get_post_meta($postid, 'RankVideo', true))  {

    $metabox_value = get_post_meta($postid, 'RankVideo', true);

    // Evaluates the string and converts it to integar or float value
    if ( strpos( $metabox_value, '.' ) === false ) {
        $ranking = (int)$metabox_value;
    } else {
        $ranking = (float)$metabox_value;
    }

    if( is_float( $ranking ) ) { // Check to see if whole number or decimal
        $rounded_ranking = round($ranking); // If decimal round it down to a whole number
        echo '<div class="bar_mortice rounded">';
        // For Loop so we can run the stars as many times as is set, with offset of 2 to because we adding half star statically adter our For loop
        for ($counter=2; $counter <= $rounded_ranking; $counter++){ 
            echo '<i class="fa fa-star"></i>';
        }
        echo '<i class="fa fa-star-half-o"></i><div>'; // Static half star used as the ranking value is a decimal and the is_float condition is met.

    } 

    else {
        echo '<div class="bar_mortice rounded">';
        // For Loop so we can run the stars as many times as is set, no offset need, as no half star required for whole number rankings
        for ($counter=1; $counter <= $ranking; $counter++){
            echo '<i class="fa fa-star"></i>';
        }
    }

} 


elseif( get_post_meta($postid, 'ecpt_rankvideo', true)) {

    $metabox_value = get_post_meta($postid, 'ecpt_rankvideo', true);

    // Evaluates the string and converts it to integar or float value
    if ( strpos( $metabox_value, '.' ) === false ) {
        $ranking = (int)$metabox_value;
    } else {
        $ranking = (float)$metabox_value;
    }

    if( is_float( $ranking ) ) {
        $rounded_ranking = round($ranking);
        echo '<div class="bar_mortice rounded">';
        for ($counter=2; $counter <= $rounded_ranking; $counter++){
            echo '<i class="fa fa-star"></i>';
        }
        echo '<i class="fa fa-star-half-o"></i><div>';

    } 

    else {
        echo '<div class="bar_mortice rounded">';
        for ($counter=1; $counter <= $ranking; $counter++){
            echo '<i class="fa fa-star"></i>';
        }
    }
} 
?>