How to manipulate this array to get the following Cartesian product? Seek efficient method

//
const spec = [
  { label: "", content: ["", "", ""] },
  { label: "", content: ["", "", ""] },
  { label: "", content: ["", "", ""] }
];

//specdatas,spec0spec1spec2spec27

const datas = [
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  },
  {
    spec0: "",
    spec1: "",
    spec2: ""
  }
  //.....
];


<?php<br>//<br>$sets = [

['', '', ''],
['', '', ''],
['', '']

];

function fuck ($sets)
{

// 
$result = [];
// 
for ($i = 0, $count = count($sets); $i < $count - 1; $iPP) {
    // 
    if ($i == 0) {
        $result = $sets[$i];
    }
    // 
    $tmp = [];
    // 
    foreach ($result as $res) {
        foreach ($sets[$i + 1] as $set) {
            $tmp[] = $res . $set;
        }
    }
    // 
    $result = $tmp;
}

return $result;

}

var_dump (fuck ($sets));

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-1bf3ec4-54b15.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-1bf3ec4-54b15.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?