Home > Article > Backend Development > PHP code PHP code that inserts a string at the specified position of the string
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
}
$str = ($startstr . $substr . $laststr);
return $str;
}
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.