This function is supposed to switch the string around a bit.
ABCD --> BADC
ABCDE --> BADCE (Even though it doesn't add the last character if the string's length is odd yet, I will add it later).
That returns nothing, though. Why? Thanks.
ABCD --> BADC
ABCDE --> BADCE (Even though it doesn't add the last character if the string's length is odd yet, I will add it later).
Code:
<?
function sss($string) {
for ($i=0; $i <= strlen($string); $i += 2) {
$chr1 = $string{$i};
$chr2 = $string{$i + 1};
$string{$i + 1} = $chr1;
$string{$i} = $chr2;
}
return $string;
}
echo sss($_GET['x']);
?>
That returns nothing, though. Why? Thanks.