Logo Luan Morina
Calculate the percentage of matching characters in two strings
Name Percentage
Brian44%
Juan75%
Leonardo33%
Liam50%
Logan67%
Luan100%
Mason44%
Owen25%
Sebastian31%
William18%

PHP

<table id="demoTable" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Percentage</th>
</tr>
</thead>
<tbody>
<?php 
$name_to_compare = "Luan";
$array_with_names = array ('Brian', 'Juan', 'Leonardo', 'Liam', 'Logan', 'Luan', 'Mason', 'Owen', 'Sebastian', 'William');
while (list($name_id, $name_example) = each($array_with_names)){
similar_text($name_example, $name_to_compare, $comparison_percentage);
echo "<tr>";
echo "<td>" . $name_example . "</td>";
echo "<td>" . round($comparison_percentage) . "%</td>";
echo "</tr>";
} 
?>
</tbody>
</table>
   Calculate the similarity of text in an array