Loop through an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nekros
Forum Newbie
Posts: 1
Joined: Tue Apr 20, 2010 12:53 pm

Loop through an array

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Loop through an array

Post 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.
(#10850)
User avatar
JAY6390
Forum Newbie
Posts: 20
Joined: Sat Apr 17, 2010 6:51 am
Location: UK

Re: Loop through an array

Post by JAY6390 »

Also you should use foreach to loop through each element of an aray
Post Reply