php - How to use variables in callback functions? -
 (how) is it possible to use a variable within a callback function? For example, I want to use the     You can use here:   $ add  variable inside my callback function:   
 private function addToWord ($ add) {return preg_replace_callback ('/ ([Az]) + / i ', function ($ word, $ add) {return word $. $ Add;}, $ this- & gt; text); }     
 
 Private function addToWord ($ add) {return preg_replace_callback ('/ ([az]) + / i', function ($ word) usage ($ add) {return $ word [1]. $ Add;}, $ this- & Gt; text); }    
 
Comments
Post a Comment