Given an input string like "TACTTGATUATC", I need to replace all the T's with A's, the G's with C's, etc. I've been using
$inputpattern = array("/A/","/T/","/G/","/C/");
$outputpattern = array("U","A","C","G");
$output = preg_replace ($inputpattern,$outputpattern,$_POST["forminput"]);
but it does not work properly. When I had it print the result of
TACTTGAGTATC[CODE]
as input, it came out as
[CODE]AUGAAGUGAUAG
,and when I tried a different input,
TACGGGGGGATC
, it came out as
AUGGGGGGGUAG
So, for some wayward reason the preg_replace consistently fails to match that third array element of the input pattern ("/G/"). Am I doing something wrong and not noticing it?