chunk_split() function in PHP || PHP chunk_split() function
×


chunk_split() function in php

1884

PHP chunk_split() function is used to breaks a PHP string into a number of parts separated by a user-defined term and return modified string. It is an inbuilt function of PHP.

Syntax:

chunk_split($string, $length, $separater);

here,

  • $string is a PHP string. It is mandatory.
  • $length is the length of every smaller part chunked by this function. It is also mandatory.
  • $separater is the user-defined character which used to separate each chunked parts. It is also a mandatory parameter.

Example:

<?php
$string="Ram's son goes to his school in the morning.\n";
$new_string=chunk_split($string,2,"-");
echo "Old string is : $string <br>";
echo "New String is :$new_string";
?>

Output:




Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments