<?php
$texto = "Olá, car#oa# cliente!\n " ;
$texto .= "Seja bem-vind#oa# à nossa central de atendimento para #hm#!\n " ;
$placeholders = array ( '#oa#' , '#hm#' /*, etc */ ) ; $masculino = array ( 'o' , 'homens' /*, etc */ ) ; $feminino = array ( 'a' , 'mulheres' /*, etc */ ) ;
$sexo = 'masculino' ;
echo str_replace ( $placeholders , $sexo == 'feminino' ?
$feminino : $masculino , $texto ) ;
$sexo = 'feminino' ;
echo str_replace ( $placeholders , $sexo == 'feminino' ?
$feminino : $masculino , $texto ) ; ?>
PD9waHAKCgkkdGV4dG8gID0gIk9sw6EsIGNhciNvYSMgY2xpZW50ZSFcbiI7CgkkdGV4dG8gLj0gIlNlamEgYmVtLXZpbmQjb2EjIMOgIG5vc3NhIGNlbnRyYWwgZGUgYXRlbmRpbWVudG8gcGFyYSAjaG0jIVxuIjsKCQoJJHBsYWNlaG9sZGVycyA9IGFycmF5KCAnI29hIycsJyNobSMnICAgICAvKiwgZXRjICovICk7CgkkbWFzY3VsaW5vICAgID0gYXJyYXkoICdvJyAgICwnaG9tZW5zJyAgIC8qLCBldGMgKi8gKTsKCSRmZW1pbmlubyAgICAgPSBhcnJheSggJ2EnICAgLCdtdWxoZXJlcycgLyosIGV0YyAqLyApOwoJCgkkc2V4byA9ICdtYXNjdWxpbm8nOwoJZWNobyBzdHJfcmVwbGFjZSggJHBsYWNlaG9sZGVycywgJHNleG89PSdmZW1pbmlubyc/JGZlbWluaW5vOiRtYXNjdWxpbm8sICR0ZXh0byApOwoKCSRzZXhvID0gJ2ZlbWluaW5vJzsKCWVjaG8gc3RyX3JlcGxhY2UoICRwbGFjZWhvbGRlcnMsICRzZXhvPT0nZmVtaW5pbm8nPyRmZW1pbmlubzokbWFzY3VsaW5vLCAkdGV4dG8gKTsKPz4=