Sfoglia il codice sorgente

new replace_first function

CauseFX 5 anni fa
parent
commit
9e7bec2dae
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  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;
-}
+}