RE: [PHP] can someone help?
| From: | Maxim Maletsky \(PHPBeginner.com\) | Date: | Wed, 24 Apr 2002 16:26:19 +0000 |
| Subject: | RE: [PHP] can someone help? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94414@lists.php.net to get a copy of this message | ||
Hey, I started playing with your code for a while ... And then
realized.. What you're trying to do it to reproduce chunk_split()
function.
Try other work arounds for this.
Read the docs,
Start from here: www.php.net/chunk_split
Sincerely,
Maxim Maletsky
Founder, Chief Developer
www.PHPBeginner.com // where PHP Begins
-----Original Message-----
From: Kirk Babb [mailto:kbcd@worldnet.att.net]
Sent: Wednesday, April 24, 2002 5:35 PM
To: php-general@lists.php.net
Subject: [PHP] can someone help?
First, here's my code:
<?php
$string="Why am I trying to do this crazy stuff when I should know
better?";
$array=preg_split("[\s]", $string);
// just a test of the preg_split results
// print_r($array);
$i=0;
$count = count($array);
$container=0;
while ($container <= 20) {
$box = strlen($array[$i]);
$container=$container + $box;
$i++;
}
$returned_string="";
$j=0;
while ($j <= $i) {
$returned_string .= $array[$j] . " ";
$j++;
}
print $returned_string . "<br>";
?>
Works great on the first line, but I'm stuck on printing the remaining
part of the array using some sort of loop. I've tried a few things but
get endless loops. In the end I'd like to make this a function and just
give it the string and the container length as arguments.....can someone
give me some advice?
THANKS! :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php