-1

enter image description here

show me how to fix this error , although there are quite a few posts but mine is a bit different . I don't understand php well thanks ! details of the error code line: $datainfo['category'] = $category['name'];

dev99
  • 11
  • 3

2 Answers2

1

For handle error, you can write code like:

$datainfo['category'] = (isset($category['name']))?$category['name']:"";
KHIMAJI VALUKIYA
  • 626
  • 1
  • 5
  • 16
1

The error states that PHP cannot find the key "name" in an array. To counteract the error, you can make the following check and assignment at the point where the array is set.

Many ways to do it:

long version

if (! isset($category['name'])) {
    $category['name'] = "";
}

medium long version

$datainfo['category'] = (isset($category['name'])) ? $category['name'] : "";

shortest version

$datainfo['category'] = $category['name'] ?? "";

Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79