Question: I have one function that calculate minute on argument base

```
function calculate_time_date($argmnt1, $argmnt2)
{
    $to_time = strtotime($argmnt2);
    $from_time = strtotime($argmnt1);
    return round(abs($to_time - $from_time) / 60,2);
}
  echo calculate_time_date('13/05/2017 16:00', '13/05/2017 19:30');
  echo '<br>';
 echo calculate_time_date('12/05/2017 16:00', '12/05/2017 19:30');`

```

now this code give result `0` and `210` 
but i need 210 for both result, can you please help me what's i imrove in my function.

Answer: 
Your Perfect Solution is here : 

```
$customerData = [];
    foreach ($userIds as $data) {

      foreach ($customerData as $k => $check) {
        if ($k == $data['user_id'] && $data['location_id'] == $check) {
          $customerData[$k][] = $data['location_id'];
        }

      }
      $customerData[$data['user_id']][] = $data['location_id'];
    }

```

[Live Demo](https://eval.in/795177)
Simply remove the `$i` usage and use `$customerData[$k][]` in your loop. This will add a new occurance to the userid array automatically and as many as exist.

```
$customerData = [];

foreach ($userIds as $data) {

    foreach ($customerData as $k => $check) {
        $customerData[$k][] = $data['location_id'];
    }

}

```