Page 1 of 1

Loop through an array

Posted: Tue Apr 20, 2010 12:59 pm
by nekros
Hello.


I've got a problem , which I couldn't solve , that's why I writing.

So ...
I have a 2 variables in which I have a data i.e 1-st variable → amount of players from a certain world. , and 2-nd variable → data of 300 best players from certain world.

I need a script which would check who from these 300 best players is online and for each of them mark with a star (*) .
I tried to do it with a function array_intersect but unfortunately I've got nothing.

Something in this kind \/

Code: Select all

$array1 = array($table[$i]['name']);
$array2 = array($myresult[$i]['name']);
$result = array_intersect($array1, $array2);

Any ideas?

Re: Loop through an array

Posted: Tue Apr 20, 2010 5:05 pm
by Christopher
This seems like the wrong way to solve this problem. Is the data in a database? If so then you should join the players table with the best players table.

Re: Loop through an array

Posted: Wed Apr 21, 2010 2:49 am
by JAY6390
Also you should use foreach to loop through each element of an aray