Browse Source

new replace_first function

CauseFX 5 years ago
parent
commit
9e7bec2dae
1 changed files with 6 additions and 1 deletions
  1. 6 1
      api/functions/normal-functions.php

+ 6 - 1
api/functions/normal-functions.php

@@ -557,6 +557,11 @@ trait NormalFunctions
 		}
 		}
 		return false;
 		return false;
 	}
 	}
+	
+	public function replace_first($search_str, $replacement_str, $src_str)
+	{
+		return (false !== ($pos = strpos($src_str, $search_str))) ? substr_replace($src_str, $replacement_str, $pos, strlen($search_str)) : $src_str;
+	}
 }
 }
 
 
 // Leave for deluge class
 // Leave for deluge class
@@ -737,4 +742,4 @@ function utf8ize($mixed)
 		return mb_convert_encoding($mixed, "UTF-8", "UTF-8");
 		return mb_convert_encoding($mixed, "UTF-8", "UTF-8");
 	}
 	}
 	return $mixed;
 	return $mixed;
-}
+}