itiswutitis Posted March 9, 2015 Share Posted March 9, 2015 When I run the code below, the count function is returning 72. Why is it not returning 64 as I think it should? <?php <$board = array(array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'),array('x', 'x', 'x', 'x', 'x', 'x', 'x', 'x'));echo "<pre>";foreach($board as $row){foreach ($row as $piece)echo "$piece ";echo "<br>";}echo "</pre>";echo count($board, 1); ?> Link to comment Share on other sites More sharing options...
Don E Posted March 9, 2015 Share Posted March 9, 2015 Maybe because it's counting the the 8 arrays inside the board array. 64 + 8 = 72 Link to comment Share on other sites More sharing options...
Ingolme Posted March 10, 2015 Share Posted March 10, 2015 Yes, that's what it's doing. 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