<?
$string = 'abcdefghijklmnopqrstuvwxyz';
$strNum = ceil(strlen($string)/8);

for ($i=0; $i<$strNum; $i++) $newString[] = substr($string, ($i*8), 8);

for ($j=0; $j<count($newString); $j++) echo "string$j = $newString[$j]<br
/>";
?>

Rick

A sense of humor can help you over look the unattractive, tolerate the
unpleasant, cope with the unexpected, and smile through the unbearable. -
Moshe Waldoks

> From: "Randy Johnson" <[EMAIL PROTECTED]>
> Date: Wed, 31 Jul 2002 15:26:15 -0400
> To: <[EMAIL PROTECTED]>
> Subject: [PHP] String Question
> 
> Hello,
> 
> I would like to be able to do the following but have not figured out a way to
> handle it
> 
> $string="abcdefghijklmnopqrstuvwxz";
> 
> I would like to divde the above string into separate strings 8 charactes long
> , example
> 
> $string1=abcdefgh
> $string2=ijklmnop
> $string3=qrstuvwx
> $string4=yz
> 
> if the string were only 10 long
> 
> $string=abcdefghij
> 
> then
> 
> $string1=abcdefgh
> $string2=ij
> 
> any suggestions would be greatly appreciated.
> 
> Thanks,
> 
> 
> Randy
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to