Home >Backend Development >PHP Tutorial >PHP code to insert a string at a specified position in the string_PHP tutorial

PHP code to insert a string at a specified position in the string_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:40:57843browse

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%

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321264.htmlTechArticleCopy the 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; $jstrlen($str); $j++){ $last. ..
Statement:
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