thendal
Programmer
- Aug 23, 2000
- 284
Hey guys!
Iam trying to make an array values as unique.
for example iam having an array
@a=(1,2,3,4,4,5)
I need an output @a=(1,2,3,4,5);
I tried like this.
for($i=0;$i<@a;$i++)
{
for($j=$i+1;$j<@a;$j++)
{
if($i eq $j)
{
splice(@a,$j,1);
}
}
}
using this i got the output 12345
But when i change the array values to some thing like this
@a=(1,2,3,4,4,4,4,4,4,4,5)
its giving an output not with the unique values
@a=(1,2,3,4,4,4,5)
I know iam missing some where in logic ,I hope u can help me.
[sig][/sig]
Iam trying to make an array values as unique.
for example iam having an array
@a=(1,2,3,4,4,5)
I need an output @a=(1,2,3,4,5);
I tried like this.
for($i=0;$i<@a;$i++)
{
for($j=$i+1;$j<@a;$j++)
{
if($i eq $j)
{
splice(@a,$j,1);
}
}
}
using this i got the output 12345
But when i change the array values to some thing like this
@a=(1,2,3,4,4,4,4,4,4,4,5)
its giving an output not with the unique values
@a=(1,2,3,4,4,4,5)
I know iam missing some where in logic ,I hope u can help me.
[sig][/sig]