
Коллеги добрый день!
Помогите понять, в чём причина сообщения "PHP Notice: Undefined offset:"
Код:
```
<?php
$info = shell_exec("systemctl --state=failed | grep failed");
$array_lines = explode("\n", $info);
print_r($array_lines);
foreach ($array_lines as $value){
$array_spaces = explode(" ", $value);
print_r($array_spaces);
echo "\n" . $array_spaces[1] . "\n";
}
```
При выводе:
```
Array
(
[0] => ● httpd.service loaded failed failed The Apache HTTP Server
[1] => ● systemd-hostnamed.service loaded failed failed Hostname Service
[2] =>
)
Array
(
[0] => ●
[1] => httpd.service
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
[12] =>
[13] =>
[14] => loaded
[15] => failed
[16] => failed
[17] => The
[18] => Apache
[19] => HTTP
[20] => Server
)
httpd.service
Array
(
[0] => ●
[1] => systemd-hostnamed.service
[2] => loaded
[3] => failed
[4] => failed
[5] => Hostname
[6] => Service
)
systemd-hostnamed.service
Array
(
[0] =>
)
PHP Notice: Undefined offset: 1 in /SCRIPT/check_systemctl.php on line 11
```








