Explorar el Código

new replace_first function

CauseFX hace 5 años
padre
commit
9e7bec2dae
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      api/functions/normal-functions.php

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

@@ -557,6 +557,11 @@ trait NormalFunctions
 		}
 		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
@@ -737,4 +742,4 @@ function utf8ize($mixed)
 		return mb_convert_encoding($mixed, "UTF-8", "UTF-8");
 	}
 	return $mixed;
-}
+}