I needed help in converting following perl function into php:
sub texttool {
$tool =~ tr/A-Z/a-z/;
@tool = split(/ /, $tool);
foreach $word(@tool) {
$tit1 = $word;
$tit2 = $word;
$tit1=(($tit1=~/(.{0,1})/) ? $1 : '');
$tit2 = reverse $tit2;
chop($tit2);
$tit2 = reverse $tit2;
$tit1 =~ tr/a-z/A-Z/;
$word = "$tit1$tit2";
}
$tool = join(' ',@tool);
}
as far as i can tell in php it would be something like this
[PHP]
function texttool($tool){
$tool = strtolower($tool);
$toolarr = split(' ',$tool);
$toolarr2 = array()
foreach($toolarr as $word){
$tit1 = $word;
$tit2 = $word;
$tit2 = substr(strrev($tit2),0,strlen($tit2)-1);
$tit1 = substr(strtoupper($tit1),0,1);
$toolarr2[] = $tit1.$tit2
}
return implode(' ',$toolarr2);
}
[/PHP]
To write it out the textool accepts a string that gives it back capitalized with the first letter of the word and the rest of the word reversed with the last letter cut off.