I understand You need to first split the string into sentences. For example the "?", to do this pick
and then in a loop to check if each individual sentence the word "as" and consider its occurrence, for it has
And in General, to ask questions, to put it mildly , not yours. Try yourself in music )))) Very difficult to understand what You want to achieve and why. of course also links You gave by formula, and distribute something about php, but in General he's right. Should read about php, at least a little bit.