Return to Snippet

Revision: 16254
at July 30, 2009 00:58 by jlvallelonga


Initial Code
function insertString($toInstInto, $toInst, $position) {
	$firstHalf = substr($toInstInto, 0, $position);
	$lastHalf = substr($toInstInto, $position);
	$newString = $firstHalf . $toInst . $lastHalf;
	return $newString;
}

Initial URL
http://justpushbuttons.com/examples/insert_string_example.php

Initial Description
use this function to insert a string into another string at a certain position.<br>
echo insertString("legendary", " wait for it ... ", 5);<br>
legen wait for it ... dary

Initial Title
insertString PHP

Initial Tags
php

Initial Language
PHP