I’ve got this 2 variables that I want to compare on a certain way. So I already figured out that I have to put it in a array and compare them that way. But there’s the problem.
If my input is ‘rieebbb’, random sequence.
And my other input is ‘beer’ as in, the word beer.
How do I check if the letters in beer are all in ‘rieebbb’ and that I all use them once?
So ‘riebbb’ shouldn’t give a positive answer because I am missing a ‘e’ in the random sequence.
I’ve already tried array_intersect() but that did’nt totaly work because it didn’t check for letters already used in array 1.
Do a frequency match..count the occurrence of each character in say “beer” and store that in an array A.
That would be {{b,1},{e,2},{r,1})..
Do the same on your target string.
Compare the two arrays for the letters in the array A.
That should solve it.
Here’s the code for the same: