Ustag Posted April 6, 2012 Share Posted April 6, 2012 Hello, I have a problem comparing arrays and printing them. My code looks soemthing like this: $players_world = array();$players_world[] = $td->nodeValue; $players_guild = array();$players_guild[] = $td2->nodeValue; echo array_intersect($players_world, $players_guild); This should print a number of names but I only get "Array", how come? Link to comment Share on other sites More sharing options...
astralaaron Posted April 6, 2012 Share Posted April 6, 2012 it sounds like the array_intersect() function is returning an array. try this to quickly see the values in the array: $results = array_intersect($players_world, $players_guild);print_r($results); edit: you cant just echo out the array you would need to specify which of the values in the array that you want to echo out. http://www.w3schools.com/php/php_arrays.asp Link to comment Share on other sites More sharing options...
Ustag Posted April 6, 2012 Author Share Posted April 6, 2012 Thank you very much, my solution is this: $compare_names = array_intersect($players_world, $players_guild);foreach($compare_names as $names_online) {echo $names_online.'<br>';} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.