Home > Backend Development > PHP Tutorial > PHP code PHP code that inserts a string at the specified position of the string

PHP code PHP code that inserts a string at the specified position of the string

WBOY
Release: 2016-07-29 08:41:55
Original
1329 people have browsed it

Copy code The code is as follows:


//Insert a string
function str_insert($str, $i, $substr)
{
for($j=0; $j<$i; $j++ ){
$startstr .= $str[$j];
}
for ($j=$i; $j$laststr .= $str[$j];
}
$str = ($startstr . $substr . $laststr);
return $str;
}


Popularity: 3%

The above introduces the PHP code to insert a string of PHP code at the specified position of the string, including the content of PHP code. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template