Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,011 questions

51,958 answers

573 users

How to use chunk_split() to split a string into smaller chunks in PHP

4 Answers

0 votes
// string chunk_split( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]])

$str = "PHP Programming";
echo chunk_split($str, 1, ".");

 
/*
run: 

P.H.P. .P.r.o.g.r.a.m.m.i.n.g. 

*/

 



answered Jun 4, 2016 by avibootz
0 votes
// string chunk_split( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]])

$str = "PHP Programming";
echo chunk_split($str, 6, "...");

 
/*
run: 

PHP Pr...ogramm...ing... 

*/

 



answered Jun 4, 2016 by avibootz
0 votes
// string chunk_split( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]])

$s = "abcdefghij";
 
$res = chunk_split($s, 3);
 
echo $res; 

 
/*
run: 

abc def ghi j 

 



answered Jun 4, 2016 by avibootz
0 votes
$s = 'abcdefghij';
 
echo chunk_split(base64_encode($s), 2, ".");
 
/*
run: 

YW.Jj.ZG.Vm.Z2.hp.ag.==. 

*/

 



answered Jun 4, 2016 by avibootz

Related questions

1 answer 124 views
1 answer 136 views
1 answer 108 views
2 answers 324 views
324 views asked Jul 4, 2015 by avibootz
1 answer 203 views
3 answers 307 views
...