Forum Moderators: coopster
I put this into an array:
$code=array("A"=>1,"B"=>2,"C"=3);
How would I encode a string using this array?
$string_input="AABBCC"; ... php functions ... $string_output="112233";
Thanks
$string_output=str_replace(array("A","B","C"),array(1,2,3),$string_input);
if you're doing it in the way of $code = array('inKey1' => 'outKey1', 'inKey2' => 'outKey2', ... 'inKeyN' => 'outKeyN');
you can do
$string_output = str_replace(array_keys($code), $code, $string_input);