I had a database field containing many book titles all in uppercase. The titles were required to be propered.
I wrote a dirty solution which got the job done but there must be a more elegant solution.
Any suggestions?
Keith
I wrote a dirty solution which got the job done but there must be a more elegant solution.
Any suggestions?
Code:
$OLDBOOKS[$x]=lc($OLDBOOKS[$x]);
$OLDBOOKS[$x]=ucfirst($OLDBOOKS[$x]);
$LENF=length($OLDBOOKS[$x]);
for($y=0; $y<$LENF; ++$y){
$test=substr($OLDBOOKS[$x],$y, 1);
if($test eq ' '){
substr($OLDBOOKS[$x],$y+1,1) = ucfirst(substr($OLDBOOKS[$x],$y+1,1));
}
}
Keith