How to remove duplicate value in foreach loop in php
<?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 ) <?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)
Also in PHP:
- encryption and decryption in php example
- Carbon\Carbon::today()->format('Y-m-d') in blade
- artisan make auth
- artisan clear template cache
- Call to undefined method Illuminate\Session\Store::set()
- 0 is not inger is in php
- current date in codeigniter
- contains php
- 2 = null laravel
- eloquent get query log
- cache and compile file clear laravel
- collection get first element laravel
- case php try catch
- date format H:i:s php
- cors header ‘access-control-allow-origin’ missing IN PARTICULAR CAKEPHP API
- check gettype is string php
- check word is in string php
- date('r') php
- can we find like directorries in php
- debug php with print
- check if substring present in string in php
- carbon random future date
- changing php version in composer in server
- config cache clear with code laravel