T
T
tltary2018-04-09 14:11:39
PHP
tltary, 2018-04-09 14:11:39

How to collect to collect the third from two arrays?

There are two arrays
first

array (size=148)
  0 => 
    array (size=6)
      'id_1' => string '1' (length=1)
      'id_2' => string '6' (length=2)
      'text' => string 'Lorem ipsum' (length=16)
      'insert_time' => string '0000-00-00 00:00:00' (length=19)
      'update_time' => string '0000-00-00 00:00:00' (length=19)
      'is_check' => string '0' (length=1)
  1 => 
    array (size=6)
      'id_1' => string '1' (length=1)
      'id_2' => string '2' (length=2)
      'text' => string 'Lorem ipsum' (length=16)
      'insert_time' => string '0000-00-00 00:00:00' (length=19)
      'update_time' => string '0000-00-00 00:00:00' (length=19)
      'is_check' => string '0' (length=1)
...

second
array (size=221)
  0 => 
    array (size=3)
      'id_2' => string '6' (length=2)
      'title' => string 'ipsum' (length=30)
      'address' => string 'lorem' (length=42)
  1 => 
    array (size=3)
      'id_2' => string '2' (length=2)
      'title' => string 'lorem' (length=30)
      'address' => string 'ipsum' (length=39)
...

you need to collect a third array that will look like this
0 => 
    array (size=3)
      'id_1' => string '1' (length=1)
      'text' => string 'Lorem ipsum' (length=16)
      'insert_time' => string '0000-00-00 00:00:00' (length=19)
      'update_time' => string '0000-00-00 00:00:00' (length=19)
      'value' => 
        array (size=28)
          0 => 
            array (size=3)
              'id' => string '6' (length=2)
              'title' => string 'ipsum' (length=30)
              'address' => string 'lorem' (length=42)
              'is_check' => string '0' (length=1)
          1 => 
            array (size=3)
              'id' => string '2' (length=2)
              'title' => string 'ipsum' (length=30)
              'address' => string 'lorem' (length=42)
              'is_check' => string '0' (length=1)

how to do this with php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Prince of Denmark, 2018-04-13
@pezdatskiy

Foreach ($arr1 as $num=>&$el) {
$el[your key] = $arr2[$num][more key];
.......
$el[value] = $arr2;
Foreach ($el[value] as &$one) {
$one['is_check'] = $el['is_check'];
}
}
// deliver the quotes yourself, from the phone ☺️ inconvenient)).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question