I knew there was a difference, but 3 times! whoa!Ex.vsCode: Select all
$keys = array("apples", "oranges", "mangoes", "tomatoes", "pickles"); if (in_array('mangoes', $keys)) { ... }
The bottom search mechanism is roughly 3 times faster.Code: Select all
$keys = array("apples" => 1, "oranges" => 1, "mangoes" => 1, "tomatoes" => 1, "pickles" => 1); if (isset($keys['mangoes'])) { ... }
Performance Implications of count()
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK