Has anyone got advice about pronoun substitution? I'd like to make this easy for users, using form %keywords% that will get substituted with a php str_replace array. But it's tough in English.
Example:
$input='%his% house is %his%, and you can visit %him% there.';
$from[]='%his%';$from[]='%him%';
if($gender=='male'){
$to[]='his';$to[]='him';
}
else{
to[]='hers';$to[]='her';
}
echo str_replace($from, $to, $input);
outputs:
his house is his and you can visit him there <<= OK!
hers house is hers and you can visit her there <<==SUCKS!!
Example2:
$input='%her% house is %hers%, and you can visit %her% there.';
$from[]='%hers%';$from[]='%her%';
if($gender=='male'){
$to[]='his';$to[]='him';
}
else{
to[]='hers';$to[]='her';
}
echo str_replace($from, $to, $input);
outputs:
him house is his and you can visit him there <<= SUCKS!!
her house is hers and you can visit her there <<==OK!!
Sometimes I hate english. Any ideas on how to manage this?
FYI, this answer produces the same bad output.