Parcourir la source

new replace_first function

CauseFX il y a 5 ans
Parent
commit
9e7bec2dae
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  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;
-}
+}