How about:
$enc="abcdefe";
echo "swap: ".$enc."\n";
// swap 1st and 2nd half of string
$len= (int)strlen($enc)/2;
$enc=substr($enc,$len).substr($enc,0,$len);
echo "swp2: ".$enc."\n";
echo "end\n";
Your /2 system wont' work when strlen is an odd number.
Sean
-----Original Message-----
From: Jens Kisters [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 19 September 2001 2:43 AM
To: [EMAIL PROTECTED]
Subject: [PHP] when logic fails, PHP randomly skips execution of lines
Hello everbody,
I have noticed something quite strange,
i have a piece of code that looks like, i removed some of it to make it
readable:
there are no statements in the code that would cause the termination of the
method before reaching the last line, no return, die or whatever.
<?
echo "\nBegin\n";
/* some code that builds a string of a few hundred bytes*/
/* a loop that ads ads numbers to the ascii vals of those string named $enc
*/
/* a loop that swaps all the neighboring chars in the string */
echo "swap: ".$enc."\n";
// swap 1st and 2nd half of string
$len=strlen($enc);
$enc=substr($enc,$len/2,$len/2).substr($enc,0,$len/2);
echo "swp2: ".$enc."\n";
echo "end\n";
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]