<?php $repl = array("X" => "A","Y" => "B","Z" => "C"); $input = "XYZABC"; echo strtr($input, $repl); ?>