Help please style 2 arrays of arrays: There are 2 arrays:
array:19 [▼ 0 => array:3 [▼ 0 => "Арендатор" 1 => "Возвраты<br>(РУБ, ВКЛ. НДС)" 2 => "Возвраты<br>(ШТ.)" ] 1 => array:3 [▼ 0 => "one" 1 => "-25 900,00" 2 => -7.0 ] 2 => array:3 [▼ 0 => "two" 1 => "-22 498,00" 2 => -2.0 ] ] and the second array
array:25 [▼ 0 => array:10 [▼ 0 => "Арендатор" 1 => "Продажи<br><span>(руб, вкл. ндс)</span>" 2 => "Продажи<br><span>(шт.)</span>" 3 => "Возвраты<br><span>(руб, вкл. ндс)</span>" 4 => "Возвраты<br><span>(шт.)</span>" 5 => "Продажи<br>с учетом возвратов<br><span>(руб, вкл. ндс)</span>" 6 => "Продажи<br>с учетом возвратов<br><span>(шт.)" 7 => "Ср. ст-ть товара<br><span>(руб, вкл. ндс)" 8 => "Кол-во чеков<br><span>(шт.)</span>" 9 => "Средний чек<br><span>(руб, вкл. ндс)</span>" ] 1 => array:10 [▼ 0 => "<a href="/dashboard?date_start=2018-02-01&date_end=2018-02-23&as_user=two">two</a>" 1 => "" 2 => "" 3 => "" 4 => "" 5 => "526 077,00" 6 => 270.0 7 => "1 948,43" 8 => 171 9 => "3 076,47" ] 2 => array:10 [▼ 0 => "<a href="/dashboard?date_start=2018-02-01&date_end=2018-02-23&as_user=one">one</a>" 1 => "" 2 => "" 3 => "" 4 => "" 5 => "13 340,00" 6 => 10.0 7 => "1 334,00" 8 => 10 9 => "1 334,00" ] I need in the second array in the 3rd and 4th row to write data from 1 array (1st and 2nd row, respectively), provided that the name in the second (0-string, that part that is enclosed in <a></a> ) corresponds the name in the first array (also zero line)
I understand that you need to create a new array and loop through both arrays and write to a new one, but in fact some errors take off.
$merge = []; for ($i = 0; $i < count($array['sells']); $i++) { $merge[$i] = $array['sells'][$i]; if(in_array(substr(strstr($merge[$i][0], '>'), 1, -4),$array['refunds'][$i][0] )){ $merge[$i][4] = $array['refunds'][$i][2]; } } I did this, but $ array ['refunds'] [$ i] [0] produces strings, not an array. I can’t understand, so paste the code.