Check if a string contains an item in an array
Posted: Thu Feb 28, 2013 3:20 am
Ok I feel really lame for asking this. I swear I know this in the back of my mind somewhere. I'm so out of practice :/
So I'm trying to come up with a quick PHP application that can convert a strand of DNA into mRNA and/or mRNA into tRNA (or however that works—I'm not following this unit that well ). The way it works is you select which nucleic acid it is, and input a sequence, and it outputs the conversion by replacing each base with its corresponding pair.
Anyway, I'm having trouble checking that the inputted sequence contains only legitimate base pairs—A, T, U, G, and C. What I have is an array containing each of those letters, and I'm not quite sure how to check that the string only contains characters existing in the array. Any help (or alternate solutions) would be greatly appreciated!
I should probably focus more on the conversion than the checks… or more importantly, my actual homework. But that's not fun.
So I'm trying to come up with a quick PHP application that can convert a strand of DNA into mRNA and/or mRNA into tRNA (or however that works—I'm not following this unit that well ). The way it works is you select which nucleic acid it is, and input a sequence, and it outputs the conversion by replacing each base with its corresponding pair.
Anyway, I'm having trouble checking that the inputted sequence contains only legitimate base pairs—A, T, U, G, and C. What I have is an array containing each of those letters, and I'm not quite sure how to check that the string only contains characters existing in the array. Any help (or alternate solutions) would be greatly appreciated!
I should probably focus more on the conversion than the checks… or more importantly, my actual homework. But that's not fun.