Foreach has to foreach another array? for noodles.

subscription what if you need foreach in [] ?

$data[] = [
        "name" => $key["add_hour"].":00",
        "data" => [[  
          "x" => (int) $key["add_date"],
          "y" => (int) $key["times"]
        ]
        //  x  y]
      ];

like this

$data [] = [

]
    "name" => $key["add_hour"].":00",
    "data" => [[  
      "x" => (int) $key["add_date"],
      "y" => (int) $key["times"]
    ],
    [  
      "x" => (int) $key["add_date"],
      "y" => (int) $key["times"]
    ],
    [  
      "x" => (int) $key["add_date"],
      "y" => (int) $key["times"]
    ]]
  ];

if the assignment process can be modified, nest the array directly in the data outer layer

$data[] = [
  'name' => '1',
  'data' => [
    ['x' => 1, 'y' => 2]
  ]
];

if it doesn't work, do the conversion through another loop

foreach ($data as &$item) {
  $item['data'] = [$item['data']];
}
< hr >

just nest directly in the loop

$data[] = [
  'name' => '1',
  'data' => [
    ['x' => 1, 'y' => 2],
    ['x' => 3, 'y' => 4]
  ]
];

foreach ($data as $item) {
  foreach ($item['data'] as $child) {
    var_dump($child); //array(2) { ["x"]=> int(1) ["y"]=> int(2) } array(2) { ["x"]=> int(3) ["y"]=> int(4) }
  }
}

if you need to manipulate an array, remember to add &

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf5903-317cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf5903-317cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?