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..