Get only the raw values of an array in Laravel Php after using array_diff()

arrays, laravel-5.4, php

Solution

You can use array_values to get it. Try this,

array_values($result);

Problem

I am using arra_diff() to remove any matching element. but the returned results contains key and values. I am only interested in the values and not the keys. below is the output: ``` array 1: [5,7,11,14,15,22,23,24] array 2: [19,7] Result (I dont like this): {"0":5,"2":11,"3":14,"4":15,"5":22,"6":23,"7":24} I need: [5,11,14,15,22,23,24] ``` mycode ``` $array_1 = query->get()->pluck('id')->toArray(); $array_2 = query->get()->pluck('id')->toArray(); $result = array_diff($array_1, $array_2); return $result ```

Original source