I have a database with one table of two columns FirstName
and LastName
and my names are Bruce Wayne
, so what I want is an output that will give me this:
a 1 10%
B 1 10%
c 1 10%
e 2 20%
n 1 10%
r 1 10%
u 1 10%
W 1 10%
y 1 10%
How many times each character has occurred in both names and what is the percentage of occurrence overall. I am new to php and mysql a little help would be welcome. Thus far I have found this http://php.net/manual/en/function.substr-count.php
$text = 'This is a test';
echo strlen($text); // 14
echo substr_count($text, 'is'); // 2
I don't know if the best approach would be php or sql. Thanks!