Array and string offset access syntax with curly braces is deprecated
Description
PHP used to support the curly braces {} to access elements in an array and a string. This was deprecated in PHP 7.4 and abandoned in PHP 8.0. The only operator to access an element is the square brackets [].
Example
<?php
$string = 'abc';
echo $string{1}; // b
$array = ['A', 'B', 'C'];
echo $array{1}; // B
?>
Alternatives
- Switch to the square brackets.
- Use the substr() function to extract one string char.
In more recent PHP versions, this error message is now :ref:array-and-string-offset-access-syntax-with-curly-braces-is-no-longer-supported.
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See curly_braces