Answers for "array unique in laravel"

PHP
18

php remove duplicates from array

<?php
$fruits_list = array('Orange',  'Apple', ' Banana', 'Cherry', ' Banana');
$result = array_unique($fruits_list);
print_r($result);
?>
  
Output:

Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry )
Posted by: Guest on March-04-2020
2

get unique values in laravel

$users = User::select('name')->distinct()->get();
Posted by: Guest on February-19-2021

Browse Popular Code Answers by Language