string chunk_split function - insert sub-string into a string after an specified length
string-chr-function-example-in-php.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>string chunk_split function - insert sub-string into a string after an specified length</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="string chunk_split function - insert sub-string into a string after an specified length">
<meta name="keywords" content="php, example, code, array, function, chunk_split, string">
<meta name="description" content="string chunk_split function - insert sub-string into a string after an specified length">
<style>
h2, h4{background:#eee; color:#000078;}
h2{ padding:3px; margin:3px; font-size:21px;}
h4{ padding:2px; margin:2px; font-size:16px;}
p{padding:2px; margin:2px; color:#3333Fe;}
body{ background:#FFFFFd;}
</style>
</head>
<body>
<h2>string chunk_split function - insert sub-string into a string after an specified length</h2>
<pre>
<?php
/*
------------------------------------------
let us take a string to test the function
------------------------------------------
*/
$myString = "my seo boss suman vhi is married.";
echo "<h4>Output of myString</h4>";
print "<p>$"."myString = {$myString}</p>";
/*
------------------------------------------------------------------------------------------
now we want to add sub-string test after every 5 character of the given string
by using chunk_split function
------------------------------------------------------------------------------------------
*/
$finalString = chunk_split($myString, 5, '#test#');
echo "<h4>Output of finalString by using string chunk_split function</h4>";
print "<p>$"."finalString = {$finalString}</p>";
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..