Ustag Posted April 6, 2012 Share Posted April 6, 2012 (edited) 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? Edited April 6, 2012 by Ustag Link to comment Share on other sites More sharing options...
astralaaron Posted April 6, 2012 Share Posted April 6, 2012 (edited) 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 Edited April 6, 2012 by astralaaron 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>';} 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now