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 $ 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); }    

You can use here:

  Private function addToWord ($ add) {return preg_replace_callback ('/ ([az]) + / i', function ($ word) usage ($ add) {return $ word [1]. $ Add;}, $ this- & Gt; text); }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

Installing croogo for cakephp -