A small function that inserts a string at a specified position in a string:
<?php //插入一段字符串 function str_insert($str, $i, $substr) { for($j=0; $j<$i; $j++){ $startstr .= $str[$j]; } for ($j=$i; $j<strlen($str); $j++){ $laststr .= $str[$j]; } $str = ($startstr . $substr . $laststr); return $str; } ?>
The above is the content of a small function that inserts a string at a specified position in a string. For more related content, please pay attention to the PHP Chinese website (www.php .cn)!
Related articles: