0

I'm trying to understand Anonymous Functions in php (laravel framework) , I searched about my basic question here but I didn't find the answer.

echo preg_replace_callback('~-([a-z])~', function ($match) {
    return strtoupper($match[1]);
}, 'hello-world');
// outputs helloWorld

What parameters gone inside the anonymous function ??

Route::match(['get', 'post'], '/', function () {
    return 'Hello World';
});
1
  • 3
    It depends on what's calling the anonymous function. Read the description of preg_replace_callback to see what arguments it sends. Commented Jul 23, 2015 at 21:07

1 Answer 1

1

http://php.net/preg_replace_callback

A callback that will be called and passed an array of matched elements in the subject string. The callback should return the replacement string. This is the callback signature:

So it sends in the array of matches.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.