How to echo the latest time a value appear into a set of arrays

  arrays, delay, echo, foreach, php

I have 10 sets of numbers into array, representing different days.

<?php 
$day1 = ['23', '11', '52', '33', '1', '4']; 
$day2 = ['66', '70', '55', '8', '22', '1'];
$day3 = ['38', '21', '52', '51', '53', '9'];
$day4 = ['14', '31', '54', '5', '73', '39'];
$day5 = ['10', '3', '22', '59', '73', '39'];
$day6 = ['22', '13', '4', '5', '73', '39'];
$day7 = ['40', '3', '22', '5', '13', '30'];
$day8 = ['88', '53', '4', '25', '71', '19'];
$day9 = ['10', '30', '49', '25', '73', '46'];
$day10 = ['10', '3', '4', '5', '73', '11'];

I need to echo the latest time a number has been seen into the sets, considering that $day1 is the older moment, while $day10 is the most recent.

Example : number 73 appears in day 4, 5, 6, 9 and 10, but I’m interested only in the most recent one so I should print

73 last seen on day 10

I would like to be able also to print aggregate values, like this :

last seen since day 10 : '10', '3', '4', '5', '73', '11'
last seen since day 9 : '30', '49', '25', '46'
last seen since day 8 : '88', '53', '71', '19'
last seen since day 7 : '40', '22'. '13'

I’m really new to php, so i was trying by exploding the values, then introducing a foreach cycle

enter $myArray1 = explode(" " $day1);
$myArray2 = explode(" " $day2);
$myArray3 = explode(" " $day3);
$myArray4 = explode(" " $day4);
$myArray5 = explode(" " $day5);
$myArray6 = explode(" " $day6);
$myArray7 = explode(" " $day7);
$myArray8 = explode(" " $day8);
$myArray9 = explode(" " $day9);
$myArray10 = explode(" " $day10);
print_r ($myArray1);
foreach ($myArray1 as $value);
{   
echo "$value <br>";
$array[] = $value;
}

But I’m definetely clueless. Can anyone help me ?
thanks

Source: Ask PHP

LEAVE A COMMENT