php - remove_before() -


Is there a better way to do the down? (Without the possibility of a fatal error)

  Before removing the function ($ needle, $ hansstack) {return substr (strstr ($ haystack, $ needle), strlen ($ needle)); }  

such as strstr ($ haystack, $ needle) but without the needle in the returned string, and I can also ask if it can also be improved ...

Note that after the last incident of the needle remove the wire after the strips, and before the first appearance of the needle remove before the wire strips.

edit: Example:

  $ needle = '@@'; $ Haystack = 'one @@ two @@ three' ;; ($ Needle, $ hansstack); // a return @ @ two before removing ($ needle, $ hansstack): // return two @@ three  

edit: I will leave for reference.

There are two things about the function Written:

They have an error handling For example, in remove_before: due to the green color in the dry drain is due to passing the false as the first argument of substr i do it Have not tried, but I'm pretty sure this would be a runtime error.

Therefore:

  Before removing the function ($ needle, $ harestack) {$ pos = strpos ($ haystack, $ needle)); // No needle is found (wrong === $ pos) $ green stack; Return substrate ($ histoc, $ position + strollon ($ needle)); }  

and so on, after remove_after :

function deleted ($ Needle, $ Harestack) {$ pos = Strrpos ($ yesstack, $ needle); // No needle is found (wrong === $ pos) $ green stack; Return substrate ($ haystack, 0, $ pos); }

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -