Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,239 questions

56,142 answers

573 users

How to remove duplicate values from an array in PHP

5 Answers

0 votes
$array = array(" PHP ", " Java ", " Python ", " PHP ");
  
$array = array_unique($array);
      
print_r($array)
  
   
/*
run:
    
Array ( [0] => PHP [1] => Java [2] => Python )
    
*/

 



answered Nov 16, 2017 by avibootz
0 votes
$array = array("PHP", "Java", "PHP", "Python", "PHP");
   
$array = array_keys(array_flip($array)); 
       
print_r($array);
   
    
/*
run:
     
Array ( [0] => PHP [1] => Java [2] => Python ) 
     
*/

 



answered Mar 3, 2019 by avibootz
0 votes
$array = array( 0 => 'php', 
                1 => 'java', 
                2 => 'php', 
                3 => 'python', 
                4 => 'php', 
              ); 
   
$array = array_keys(array_flip($array)); 
       
print_r($array);
   
    
/*
run:
     
Array ( [0] => php [1] => java [2] => python ) 
     
*/

 



answered Mar 3, 2019 by avibootz
0 votes
$array = array( 0 => 'php', 
                1 => 'java', 
                2 => 'php', 
                3 => 'python', 
                4 => 'php', 
              ); 
   
$array = array_unique($array);
       
print_r($array);
   
    
/*
run:
     
Array ( [0] => php [1] => java [3] => python ) 
     
*/

 



answered Mar 3, 2019 by avibootz
0 votes
$array = array( 0 => 50, 
                1 => 60, 
                2 => 50, 
                3 => 60, 
                4 => 50, 
              ); 
   
$array = array_unique($array);
       
print_r($array);
   
    
/*
run:
     
Array ( [0] => 50 [1] => 60 ) 
     
*/

 



answered Mar 3, 2019 by avibootz

Related questions

2 answers 311 views
1 answer 219 views
1 answer 227 views
3 answers 230 views
1 answer 197 views
...