<?php

	function substituir( $texto, $arr ) {
	   foreach ($arr as $key => $value) {
	      $texto = str_replace ( $key, $value, $texto);
	   }
	   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";

?>