Есть скрипт. Который выводит результат вычислений на экран. Подскажите, как можно вывести результат в процентах?
function qmn_variable_average_category_points( $content, $mlw_quiz_array ) {
$return_points = 0;
while ( strpos( $content, '%AVERAGE_CATEGORY_POINTS%' ) !== false || false !== strpos($content, '%AVERAGE_CATEGORY_POINTS_') ) {
$return_points = 0;
$total_questions = 0;
preg_match( "~%AVERAGE_CATEGORY_POINTS%(.*?)%/AVERAGE_CATEGORY_POINTS%~i", $content, $answer_text );
if(empty($answer_text)){
$category_name = mlw_qmn_get_string_between($content, '%AVERAGE_CATEGORY_POINTS_', '%');
}else{
$category_name = $answer_text[1];
}
foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
if ( $answer["category"] == $category_name ) {
$total_questions += 1;
$return_points += $answer["points"];
}
}
if ( $total_questions !== 0 ) {
$return_points = round( $return_points / $total_questions, 2 );
} else {
$return_points = 0;
}
if(empty($answer_text)){
$content = str_replace( '%AVERAGE_CATEGORY_POINTS_'.$category_name.'%' , $return_points, $content);
}else{
$content = str_replace( $answer_text[0] , $return_points, $content);
}
}
return $content;
}