Re: String Question
| From: | Richard Baskett | Date: | Wed, 31 Jul 2002 19:46:57 +0000 |
| Subject: | Re: String Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110561@lists.php.net to get a copy of this message | ||
<?
$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" <icgphp@icecoldgold.com>
> Date: Wed, 31 Jul 2002 15:26:15 -0400
> To: <php-general@lists.php.net>
> 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
>