Let's say that
$result='first';
when I do:
$result.='second';
I got 'first second' instead of 'firstsecond'. How to perfom concatenatation without adding this whitespace?
Edit:
That's the code. It should translate simple string to "pilots alphabet".
function converting($words){
echo $words;
global $result;
$result='';
for($x=0; $x<strlen($words); $x++){
switch($words{$x}){
case ' ':
$result.=' ';
break;
case 'A':
$result.='Alfa';
break;
case 'B':
$result.='Bravo';
break;
case 'C':
$result.='Charlie';
break;
case 'D':
$result.='Delta';
break;
case 'E':
$result.='Echo';
break;
case 'F':
$result.='Foxtrot';
break;
case 'G':
$result.='Golf';
break;
case 'H':
$result.='Hotel';
break;
case 'I':
$result.='India';
break;
case 'J':
$result.='Juliett';
break;
case 'K':
$result.='Kilo';
break;
case 'L':
$result.='Lima';
break;
case 'M':
$result.='Mike';
break;
case 'N':
$result.='November';
break;
case 'O':
$result.='Oscar';
break;
case 'P':
$result.='Papa';
break;
case 'Q':
$result.='Quebec';
break;
case 'R':
$result.='Romeo';
break;
case 'S':
$result.='Sierra';
break;
case 'T':
$result.='Tango';
break;
case 'U':
$result.='Uniform';
break;
case 'V':
$result.='Victor';
break;
case 'W':
$result.='Whiskey';
break;
case 'X':
$result.='Xray';
break;
case 'Y':
$result.='Yankee';
break;
case 'Z':
$result.='Zulu';
break;
}
}
return $result;
}
That switch also adds some cases that I have not defined. It is adding other characters to result, like '?' or '!' if they appear in 'words' string.
.=operator does not add space. The space is already in one of your strings.trim()on the string before concatenationcase ' ':