user3080585
user3080585

Reputation: 1

preg_replace_callback(): Requires argument 2

I'm not quite sure what to do here. Any help from someone smarter than I would be greatly appreciated...

Warning: preg_replace_callback(): Requires argument 2, 'strtolower(':0')', to be a valid callback in ....\ on line 380.

$css = preg_replace_callback('/(text-shadow\:0)(;|\})/ie', "strtolower('$1 0 0$2')", $css);

Upvotes: 0

Views: 8557

Answers (1)

lonesomeday
lonesomeday

Reputation: 237855

That isn't a callback. It's a string containing PHP code: an entirely different thing. A callback would look like this:

$css = preg_replace_callback('/(text-shadow\:0)(;|\})/ie', function($matches) {
    return strtolower($matches[1] . " 0 0" . $matches[2]);
}, $css);

To be precise, the second argument needs to be a "callable". This can be a string, when that string is the name of a function. If you are using an old version of PHP, you will need to do it that way:

function handleMatch($matches) {
    return strtolower($matches[1] . " 0 0" . $matches[2]);
}
$css = preg_replace_callback('/(text-shadow\:0)(;|\})/ie', 'handleMatch', $css);

Upvotes: 1

Related Questions