[ create a new paste ] login | about

Link: http://codepad.org/LJIWedZv    [ raw code | output | fork ]

PHP, pasted on Dec 25:
1
2
3
4
5
6
7
8
9
10
<?php
  function str_insert($str, $search, $insert) {
    $index = strpos($str, $search);
    if($index === false) {
        return $str;
    }
    return substr_replace($str, $search.$insert, $index, strlen($search));
  }

  echo str_insert("The big brown dog jumped over the fence", "dog", "s");


Output:
1
The big brown dogs jumped over the fence


Create a new paste based on this one


Comments: