Some in_array logic help please?
Some in_array logic help please?
(OP)
I've been playing with this for way too long. So I thought I would ask here.
I'm trying to check if a array element value can be found as a data element in a reference array. I'm using this:
if (!in_array($arg, $arrayname, true)) {
this would occur if the $arg value is NOT found in the array
}
What I'm experiencing is even if the searched arrayname contains a substring of the $argument is returning true.
Example:
If I search for abc and the array element contains abcdef it would return found.
What do I need to do to assure the element I'm testing for is the exact same match as the argument value?
example:
If the argument was abc then the array element value must be exactly abc
Any hint, suggestions greatly appreciated.
Thanks
I'm trying to check if a array element value can be found as a data element in a reference array. I'm using this:
if (!in_array($arg, $arrayname, true)) {
this would occur if the $arg value is NOT found in the array
}
What I'm experiencing is even if the searched arrayname contains a substring of the $argument is returning true.
Example:
If I search for abc and the array element contains abcdef it would return found.
What do I need to do to assure the element I'm testing for is the exact same match as the argument value?
example:
If the argument was abc then the array element value must be exactly abc
Any hint, suggestions greatly appreciated.
Thanks
RE: Some in_array logic help please?
Are you sure ? in_array() works out of the box exactly as you described :
CODE --> -a
Could you post some exact input data samples for which it fails ?
Feherke.
feherke.ga
RE: Some in_array logic help please?
Thanks for the thoughts.