in_array() - help on what specifically would return true

Posted by Kerri on Stack Overflow See other posts from Stack Overflow or by Kerri
Published on 2010-03-26T20:47:19Z Indexed on 2010/03/26 20:53 UTC
Read the original article Hit count: 165

Filed under:
|
|

I am using in_array, and I'm trying to use it in a way where it will only return true if it's an exact match of one of the objects in the array, not just if it's "in" the array. e.g.

1. $sample_array = array('123', '234', '345');
2. $sample_array = array('23', '34', '45');

in_array('23', $sample_array);

In the above example, I would only want version 2 to return true, because it has the exact string, '23'. Version 1 returns true as well though, because the array contains instances of the string '23'.

How would I get this to work so that only version 2 returns true? Am I even using the right function?

© Stack Overflow or respective owner

Related posts about php

Related posts about php-in-array