Created
May 10, 2010 23:01
-
-
Save dgmike/396658 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| /** | |
| * Exemplo de uso: | |
| * | |
| * echo change_str(',', '|', 'a,b,c,d,e', 3); | |
| * >>> 'a,b,c,d|e' | |
| */ | |
| function change_str($str, $replacer, $string, $pos) | |
| { | |
| $y=explode($str, $string, $pos+2); | |
| if (isset($y[$pos+1])){ | |
| $y[$pos]=$y[$pos].$replacer.$y[$pos+1]; | |
| array_pop($y); | |
| } | |
| $z=implode($str, $y); | |
| return $z; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment