I have been trying to create a distinct array of country code that will take all date which is for only that country and add inside that array using a multi dimensional array in PHP but I am unable to archive.
Input Array
Array
(
[0] => Array
(
[0] => 2019-01-01
[1] => lt
[2] => passport
[3] => 30122719
[4] => 2019-03-01
[5] => 357717289
)
[1] => Array
(
[0] => 2019-01-01
[1] => pl
[2] => identity_card
[3] => 9879386836
[4] => 2018-11-01
[5] => 643023760
)
[2] => Array
(
[0] => 2019-01-02
[1] => lt
[2] => passport
[3] => 46530663
[4] => 2019-03-01
[5] => 357717289
)
[3] => Array
(
[0] => 2019-01-02
[1] => pl
[2] => identity_card
[3] => 4531480055
[4] => 2017-10-21
[5] => 324444899
)
[4] => Array
(
[0] => 2019-01-03
[1] => lt
[2] => passport
[3] => 54163812
[4] => 2019-03-01
[5] => 357717289
)
[5] => Array
(
[0] => 2019-01-03
[1] => fr
[2] => drivers_license
[3] => 95180604
[4] => 2018-07-02
[5] => 942959784
)
)
Expected output
Array
(
[lt] => Array
(
[0] => 2019-03-01
[1] => 2019-03-01
[2] => 2019-03-01
)
[pl] => Array
(
[0] => 2018-11-01
[1] => 2017-10-21
)
[fr] => Array
(
[0] => 2018-07-02
)
)
So far I have tried the following
$dist = array();
foreach ($inputArray as $key => $value) {
foreach ($value as $index => $v) {
$dist[$value[1]] = $value[4];
}
}
An the code returns the following
Array
(
[lt] => 2019-03-01
[pl] => 2016-08-01
[fr] => 2019-04-01
[de] => 2009-01-01
[uk] => 2015-09-07
[es] => 2015-09-08
[it] => 2019-02-16
)