PHP 7.2 Function create_function() is deprecated
You should be able to use an Anonymous Function (aka Closure) with a call to the parent scoped $delimiter
variable, like so:
$callbacks[$delimiter] = function($matches) use ($delimiter) {
return $delimiter . strtolower($matches[1]);
};
PHP 7.2 error Function create_function() is deprecated
Should be as simple as replacing the function call with an anonymous function.
usort($languages, function($a, $b) {
if($a[0] == $b[0]) {
return 0;
}
return $a[0] < $b[0] ? 1 : -1;
});
Need help converting deprecated Function create_function() in PHP 7.2
You can use an anonymous function.
array_walk($_REQUEST['categories'], function(&$c) { $c = "-" . $c; });
Example
$array = ['a','b','c'];
array_walk($array, function(&$c) { $c = "-" . $c; });
print_r($array);
Will produce
Array
(
[0] => -a
[1] => -b
[2] => -c
)
Function create_function() is deprecated in php7.2
create_function
has been deprecated as of php 7.2. Instead you can use anonymous_function.
if ($callback === null) {
$callback = function ($matches) {
return strtoupper($matches[1]);
};
}
Related Topics
How to Use Multiple Databases in Laravel
Converting String to Date and Datetime
When Should I Use 'Self' Over '$This'
How to Make a Request Using Http Basic Authentication With PHP Curl
Startswith() and Endswith() Functions in PHP
Accessing @Attribute from Simplexml
How to Display HTML Tags as Plain Text
How to Close a Connection Early
How to Upload File Using Curl With PHP
Why Can't I Access Datetime-≫Date in PHP'S Datetime Class
Invoking a PHP Script from a MySQL Trigger
Get the First Element of an Array
How to Create Multiple Where Clause Query Using Laravel Eloquent