0
I wonder if there is any way to mix two arrays so that their display is alternating between the elements, I’ve tried a lot and I’m not getting. Figurative example:
I got two arrays with the exit like this:
{
   "Registros_1": [
       {
           "nome": "pedro",
           "cpf:": "00000000000",
           "sexo:": "masculino"
       },
       {
           "nome": "daniel",
           "cpf:": "11111111111",
           "sexo:": "masculino"
       }
  ]},
{
     "Registros_2": [
         {
             "nome_empresa": "JD_CARNES",
             "numero:": "00000000000",
             "usuario:": "1111"
         },
         {
             "nome_empresa": "RM_CARROS",
             "numero:": "11111111111",
             "usuario:": "2222"
         }
    ]
}
I need you to leave like this:
{
   "Registros": [
       {
           "nome": "pedro",
           "cpf:": "00000000000",
           "sexo:": "masculino"
       },
       {
           "nome_empresa": "JD_CARNES",
           "numero:": "00000000000",
           "usuario:": "1111"
       },
       {
           "nome": "daniel",
           "cpf:": "11111111111",
           "sexo:": "masculino"
       },
       {
           "nome_empresa": "RM_CARROS",
           "numero:": "11111111111",
           "usuario:": "2222"
       }
  ]
}
Thanks in advance!
Use the array_merge. https://www.php.net/manual/en/function.array-merge.phpfunction
– RickPariz
I tried, this function joins the arrays but doesn’t let them alternate.
– Pedro Silva