@@ -837,4 +837,52 @@ public function is_ipv6(string $ip): bool
837837 return false ;
838838 return true ;
839839 }
840+
841+ /**
842+ * Deletes the words before the given $search word
843+ *
844+ * @param string $string
845+ * @param string $search
846+ * @return string
847+ */
848+ public function after (string $ string , string $ search ): string
849+ {
850+ if (!$ this ->checkStringForRemoveOperation ($ string , $ search ))
851+ return $ string ;
852+ return $ this ->rmExtraBlank (explode ($ search , $ string )[1 ]);
853+ }
854+
855+ /**
856+ * Deletes the words after the given $search word
857+ *
858+ * @param string $string
859+ * @param string $search
860+ * @return string
861+ */
862+ public function before (string $ string , string $ search ): string
863+ {
864+ if (!$ this ->checkStringForRemoveOperation ($ string , $ search ))
865+ return $ string ;
866+ return $ this ->rmExtraBlank (strstr ($ string , $ search , true ));
867+ }
868+
869+ private function checkStringForRemoveOperation (string $ string , string $ word ): bool
870+ {
871+ $ string = strtolower (trim ($ string ));
872+ $ word = strtolower (trim ($ word ));
873+
874+ if (empty ($ string ) || !is_string ($ string ))
875+ return false ;
876+
877+ if (empty ($ word ) || !is_string ($ word ))
878+ return false ;
879+
880+ if (!$ this ->isContains ($ string , $ word ))
881+ return false ;
882+
883+ if (str_ends_with ($ string , $ word ))
884+ return false ;
885+
886+ return true ;
887+ }
840888}
0 commit comments