in reply to Counting words..

hello,
for

if (/$keyword/i)

replace with

if (/$keyword/ig)

have a nice day