03-Apr-2023
.
Admin
Hi Dev,
This tutorial is focused on how to split a string in PHP. you'll learn how to use chunk_split() function in PHP. We will use how to split a string with a small part of the chunk using the chunk_split() function in PHP. if you have a question about how to split a string using PHP then I will give a simple example with a solution.
Now, let's see the article on how to split a string in PHP. it's a simple example of how to use the chunk_split() function in PHP. you can understand the concept of how to split a string using PHP. if you have a question about how to split a string with a small part of the chunk using the chunk_split() function in PHP then I will give a simple example with a solution.
Example 1:
<?php
//Create the variable
$str = "Welcome to nicesnippets.com";
//Split the string
$res = chunk_split($str, 2, "*");
print_r($res);
?>
Output:
We*lc*om*e *to* n*ic*es*ni*pp*et*s.*co*m*
Example 2:
<?php
//Create the variable
$str = "nicesnippets";
//Split the string
$res = chunk_split($str, 1, ".");
print_r($res);
?>
Output:
n.i.c.e.s.n.i.p.p.e.t.s.
I hope it could help you...
#PHP