Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8755665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:53:56+00:00 2026-06-13T13:53:56+00:00

How to display once elements of array ?. For example var array = [b,c,c,a,d,e,a,d]

  • 0

How to display once elements of array ?. For example

var array = ["b","c","c","a","d","e","a","d"]

show => ["a","b","c","d","e"] ?

Any example ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:53:57+00:00Added an answer on June 13, 2026 at 1:53 pm

    Use the array_unique() function to remove the duplicates and sort – http://php.net/manual/en/function.array-unique.php

    Following up with the array_values() function will remove the gaps in the array index – http://php.net/manual/en/function.array-values.php

    // initialize array
    var $array = array("b","c","c","a","d","e","a","d");
    // remove duplicates and sort by string value
    $array = array_unique($array, SORT_STRING);
    // reindex array (numeric index will have gaps where the duplicates where removed)
    $array = array_values($array);
    // show results
    print_r($array);
    

    In Javascript/jQuery you can use the unique() and sort() methods

    // initialize array
    var array = ["b","c","c","a","d","e","a","d"];
    // remove duplicate values
    array.unique();
    // sort remaining items
    array.sort();
    

    If you are sorting numbers in Javascript, you would need to pass a function, as the array is sorted lexicographically be default

    array.sort(function(a,b){return a - b;});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem An array defines these elements: var equipment = new Array( bakeware, cookware, kitchenware,
How can i display variable only once in the table. <?php $sql = mysql_query(SELECT
I want to display the posted comment once the user comments. Just to add
I have a load once jqgrid that uses a custom formatter to display checkboxes
Using VB 6 Once I run the project, How to display a previously selected
Here's the scenario: I have a private site that, once logged on, will display
I want to iterate thru single array and disable caching only for some elements.
I'd like to continuously show and hide two page elements in turn. This is
I'm trying to look up an element using the following line: elements = driver.find_elements_by_xpath(//div[@class='Display'])
The .fadeOut() method animates the opacity of the matched elements. Once the opacity reaches

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.