Question: I have a function that retrieves an array of values from a DB with a query in Laravel. I need to clean that array

From this:
2022-02-21 07:40:16

To this:
07:40:16

How can I do?

The function is this:

```php
public function singleDev(Device $deviceID)
{
    $data = DataFromRasp::where('MAC', 'C4:A5:DF:24:05:7E')->get()->pluck('RSSI', 'created_at')->toArray();
    $time_array = [];
    $rssi_array = [];
    $cnt = 0;
    foreach ($data as $key => $value) {
        array_push($time_array, $key);
        array_push($rssi_array, $value);
        if ($value < -60) {
            $cnt++;
            if ($cnt >= 2) {

            }
        }
    }
    dd($time_array);

    return view('backend.auth.user.singleDevice', compact("time_array", "rssi_array"));
}

```

Answer: 
You need to get the index of the `max` and `min` value from the `arr` and then use `splice`. Also change `i != 10;` to `i<10`

```js
var arr = [];
while (arr.length < 100) {
  var r = Math.floor(Math.random() * 100) + 1;
  if (arr.indexOf(r) === -1) arr.push(r);
}
for (let i = 0; i < 10; i++) {
  const min = arr.indexOf(Math.min(...arr));
  arr.splice(min, 1)

}
for (let i = 0; i < 10; i++) {
  const max = arr.indexOf(Math.max(...arr));
  arr.splice(max, 1)

};

console.log(arr.length)
```
You can sort the array and then use the splice method to remove the first and last 10 elements.

```
var arr = [];
while (arr.length < 100) {
  var r = Math.floor(Math.random() * 100) + 1;
  if (arr.indexOf(r) === -1) arr.push(r);
}

arr.sort((a, b) => +a - +b);

arr.splice(0, 10);

arr.splice(80, 10);

console.log(arr.length);

```