Created
February 26, 2013 19:23
-
-
Save tonylegrone/5041288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Injects a string into an existing string in the designated position. | |
* HTML should not be effected, but who knows. | |
* | |
* @param string $inject | |
* The new string to be injected. | |
* @param string $string | |
* The original string to be alter. | |
* @param int $pos | |
* The word posion to inject the new string at. Zero is ahead of the | |
* original string. | |
* @return string | |
* Returns the new injected string. | |
*/ | |
function str_inject($inject, $string, $pos) { | |
$string = explode (' ', $string); | |
array_splice($string, $pos, 0, $inject); | |
return implode(' ', $string); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment