<?php
//initialization of an element of GLOBALS
$GLOBALS['categories'] = array(1=>'z',2=>'x',3=>'c',4=>'v',5=>'r');
print_r($GLOBALS['categories']);
//another element
$GLOBALS['videos'] = array(1=>'a',2=>'b',3=>'c',4=>'d');
//some operations
$videosCategories =
array(1=>array(2,3,4,5),2=>array(12,13,14,15),3=>array(22,23,24,25),4=>array(32,33,34,35));
foreach($videosCategories as $videoId => $categories2)
$GLOBALS['videos'][$videoId]['category'] = implode(',',$categories2);
//the initial element is reqritten
print_r($GLOBALS['categories']);
Array
(
[1] => z
[2] => x
[3] => c
[4] => v
[5] => r
)
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/s7T2o:15
Stack trace:
#0 {main}
thrown in /in/s7T2o on line 15
Process exited with code 255.
Output for 8.0.0 - 8.0.6
Array
(
[1] => z
[2] => x
[3] => c
[4] => v
[5] => r
)
Warning: Only the first byte will be assigned to the string offset in /in/s7T2o on line 15
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/s7T2o:15
Stack trace:
#0 {main}
thrown in /in/s7T2o on line 15
Process exited with code 255.
Array
(
[1] => z
[2] => x
[3] => c
[4] => v
[5] => r
)
Warning: Illegal string offset 'category' in /in/s7T2o on line 15
Warning: Illegal string offset 'category' in /in/s7T2o on line 15
Warning: Illegal string offset 'category' in /in/s7T2o on line 15
Warning: Illegal string offset 'category' in /in/s7T2o on line 15
Array
(
[1] => z
[2] => x
[3] => c
[4] => v
[5] => r
)