ahmed19981973

Untitled

Apr 8th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1.   public  function addCharsAt(int $index,string $char){
  2.         $str='';
  3.         for ($i=0;$i<$this->length;) {
  4.             if ($i == $index)
  5.                 $str .= $char;
  6.             else {
  7.                 $str .= $this->string[$i];
  8.                 $i++;
  9.             }
  10.         }
  11.         $this->length++;
  12.         $this->string=&$str;
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment