<?php
function substituir( $texto , $arr ) {
foreach ( $arr as $key => $value ) {
}
return $texto ;
}
$texto = "Olá, car#oa# cliente!\n " ;
$texto .= "Seja bem-vind#oa# à nossa central de atendimento para #hm#!\n " ;
$masculino = array ( '#oa#' => 'o' , '#hm#' => 'homens' ) ; $feminino = array ( '#oa#' => 'a' , '#hm#' => 'mulheres' ) ;
$sexo = 'masculino' ;
echo substituir( $texto , $sexo == 'feminino' ? $feminino : $masculino ) . "\n " ;
$sexo = 'feminino' ;
echo substituir( $texto , $sexo == 'feminino' ? $feminino : $masculino ) . "\n " ;
?>
PD9waHAKCglmdW5jdGlvbiBzdWJzdGl0dWlyKCAkdGV4dG8sICRhcnIgKSB7CgkgICBmb3JlYWNoICgkYXJyIGFzICRrZXkgPT4gJHZhbHVlKSB7CgkgICAgICAkdGV4dG8gPSBzdHJfcmVwbGFjZSAoICRrZXksICR2YWx1ZSwgJHRleHRvKTsKCSAgIH0KCSAgIHJldHVybiAkdGV4dG87Cgl9CgoKCSR0ZXh0byAgPSAiT2zDoSwgY2FyI29hIyBjbGllbnRlIVxuIjsKCSR0ZXh0byAuPSAiU2VqYSBiZW0tdmluZCNvYSMgw6Agbm9zc2EgY2VudHJhbCBkZSBhdGVuZGltZW50byBwYXJhICNobSMhXG4iOwoJCgkkbWFzY3VsaW5vID0gYXJyYXkoICcjb2EjJyA9PiAnbycsICcjaG0jJyA9PiAnaG9tZW5zJyAgICk7CgkkZmVtaW5pbm8gID0gYXJyYXkoICcjb2EjJyA9PiAnYScsICcjaG0jJyA9PiAnbXVsaGVyZXMnICk7CgkKICAgICRzZXhvID0gJ21hc2N1bGlubyc7CgllY2hvIHN1YnN0aXR1aXIoICR0ZXh0bywgJHNleG8gPT0gJ2ZlbWluaW5vJyA/ICRmZW1pbmlubyA6ICRtYXNjdWxpbm8gKS4iXG4iOwoJCiAgICAkc2V4byA9ICdmZW1pbmlubyc7CgllY2hvIHN1YnN0aXR1aXIoICR0ZXh0bywgJHNleG8gPT0gJ2ZlbWluaW5vJyA/ICRmZW1pbmlubyA6ICRtYXNjdWxpbm8gKS4iXG4iOwoKPz4=