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

  • SEARCH
  • Home
  • 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 8603097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:14:38+00:00 2026-06-12T02:14:38+00:00

I’ve been trying to find something similar to array_unique() to the extent or removing

  • 0

I’ve been trying to find something similar to array_unique() to the extent or removing all the duplicates from an array. However in this particular case I need a comma spaced array as the result rather than an key value pair. What I’d like to do is avoid running this through a loop to do it, if I can.

So if theres something like array_unique() or something I can apply to my array there after to strip the numeric index out then I am all ears for suggestions.

Currently I am building the initial array through a loop, this look cycles over 5 to 150,000 entries of which one particular entry can have any of about 1,000 possible 3 dot style versioning numbers. This is what I am building this array of. So I have many duplicates put into the array

example:

$myarray = array();
foreach($obj as $prod)
{
   //cycling over the master loop adding all my other stuff and building it out..
   $myarray[] = $prod['version'];
}

which gives me quite a large array in the format I’d like just

Array(
   "1.0.0",
   "1.0.1",
   "3.0.2220",
   "2.0.0",
   "2.0.1",
   "1.8.11",
   "3.0.2220",
   "3.0.2220",
   "2.0.0",
   "2.0.0",
   "2.0.0"
)

Where afte the loop is complete I do.

$myarray = array_unique($myarray);

Which leaves me with an array like

Array(
  [0] = "1.0.0",
  [1] = "1.0.1",
  [2] = "3.0.2220",
  [3] = "2.0.0",
  [4] = "2.0.1",
  [5] = "1.8.11",
)

Which is not desired, what is desired as the end result is..

Array(
   "1.0.0",
   "1.0.1",
   "3.0.2220",
   "2.0.0",
   "2.0.1",
   "1.8.11",
)

Where I can then sort it out to list in order earliest to latest versions..

  • 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-12T02:14:39+00:00Added an answer on June 12, 2026 at 2:14 am

    This:

    Array(
      [0] = "1.0.0",
      [1] = "1.0.1",
      [2] = "3.0.2220",
      [3] = "2.0.0",
      [4] = "2.0.1",
      [5] = "1.8.11",
    )
    

    and this:

    Array(
       "1.0.0",
       "1.0.1",
       "3.0.2220",
       "2.0.0",
       "2.0.1",
       "1.8.11",
    )
    

    are the same thing, in PHP all arrays have an index, in the last example it’s just that is not printing them, but they are there, and if you have not explicitly specified the indexes, they are just sequencial integer numbers starting from zero, like the first example.

    In your last example, the one which apparently has no indexes, if we call it $array we can do the following to print its indexes:

    foreach ($array as $key => $value) {
       echo $key; //this will print the indexes of the array
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.