[PHP] how to divide string

2005-09-05 Thread Adi Zebic

Hi,

is there any magic function who can give me from:

$string =  abcdefghijklmnopqrstuwvxyz;

somthing like this:

abcd
efgh
ijkl
mnop
qrst
uwvx
yz

(each 'x' letters go to the next line)

Thanks a lot,

ADI

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



Re: [PHP] how to divide string

2005-09-05 Thread Shafiq Rehman
Hi Zebic

It is pretty much simple./ Look into the code

$text = abcdefghijklmnopqrstuwvxyz;
$newtext = wordwrap($text, 4, br, 1);
echo $newtext;

// if you want all these chunks in an array use it as
$array = explode(br, $newtext);

echo $array[0];
echo $array[1];
echo $array[2];

Regards
Shafiq [http://www.phpgurru.com]


On 9/5/05, Adi Zebic [EMAIL PROTECTED] wrote:
 
 Hi,
 
 is there any magic function who can give me from:
 
 $string =  abcdefghijklmnopqrstuwvxyz;
 
 somthing like this:
 
 abcd
 efgh
 ijkl
 mnop
 qrst
 uwvx
 yz
 
 (each 'x' letters go to the next line)
 
 Thanks a lot,
 
 ADI
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


Re: [PHP] how to divide string

2005-09-05 Thread Kevin Waterson
This one time, at band camp, Adi Zebic [EMAIL PROTECTED] wrote:

 is there any magic function who can give me from:
 
 $string =  abcdefghijklmnopqrstuwvxyz;
 
 somthing like this:
 
 abcd
 efgh
 ijkl
 mnop
 qrst
 uwvx
 yz


$newstring=chunk_split($string, 4, 'br /');

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



Re: [PHP] how to divide string

2005-09-05 Thread Jordan Miller
If  you are using php 5, don't forget about str_split, with 4 as the  
second parameter.

http://us2.php.net/str_split

so you could do:
echo implode(br /, str_split($string, 4));

if you still have php 4 or earlier, look at that page anyway as there  
is a workaround function in the comments for earlier  versions of php.


Jordan



On Sep 5, 2005, at 6:50 AM, Adi Zebic wrote:


Hi,

is there any magic function who can give me from:

$string =  abcdefghijklmnopqrstuwvxyz;

somthing like this:

abcd
efgh
ijkl
mnop
qrst
uwvx
yz

(each 'x' letters go to the next line)

Thanks a lot,

ADI

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







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