I have a set of data in 4 arrays
Name() Stock() UserID() Price()
I can pull the data out of the arrays in a for loop and they are related by a variable $i
for ($i=0; $i<count($Name);$i++)
{
echo $Name[$i] . ' - ' . $Stock[$i] . ' - ' . UserID[$i] . ' - ' . Price[$i];
}
This works fine
Yahoo - 1000 - 2 - $1.25
Blue - 10000 - 3 - $2.25
Pink - 3000 - 2 - $1.67
Yahoo - 4000 - 5 - $5.00
However If the Name is the same (repeated) i don't want this printed out twice
i need the above to look like
Yahoo - 1000 - 2 - $1.25
- 4000 - 5 - $5.00
Blue - 10000 - 3 - $2.25
Pink - 3000 - 2 - $1.67
I cant figure out an easy way to do this, by combining arrays, removing duplicates..
Please help... I'm lost at the moment. Thanks