Tagged Questions

The php-in-array tag has no wiki, would you like to help us create it?

about the php-in-array tag | faq | top users | hot answers | new answers | synonyms

1
vote
3answers
102 views

PHP: in_array() and multidimensional array

hi, I use in_array() to check whether a value exists in an array like below, $a = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $a)) { echo "Got Irix"; } //print_r($a); but what …
2
votes
3answers
99 views

faster than in_array?

Dear all, I need to compare a value to a set of array. However, I need to compare multiple values in foreach. If using in_array, it can be slow, real slow. Is there any faster alternative? My current …
2
votes
2answers
41 views

in_array returning false when should return true

I've got a simple script that takes a word from a form and assesses whether it exists in a file (.txt). The txt file has a single word or phrase on each line. There are no \t's or \r in the file. …
1
vote
2answers
47 views

in array sql query

I have the following inside a foreach loop (displaying my various videos), I'm trying to display some alternate text for the top three voted videos. What on earth am I doing wrong (a lot clearly)... …
1
vote
4answers
282 views

PHP in_array() can't even match a single character. Strict is set to true.

I've seen a million of these threads here already, and read through every single one. That, plus some serious Googling. UPDATE: I am rewriting this post to include complete code and explanation, so …
0
votes
2answers
70 views

in_array() - help on what specifically would return true

ANSWERED: THE FUNCTION WORKS AS I WANTED IT TO. I HAD A TYPO IN MY TEST PHP THAT MADE IT RETURN TRUE REGARDLESS. I am using in_array, and I'm trying to use it in a way where it will only return true …
0
votes
2answers
118 views

check existence of an object in array

Hi, at first I wanna say that I'm new in PHP. I have an implementation that checks an object is in array or not, if not adds another array. But it always returns false and adds in theorder array. …
0
votes
3answers
77 views

Problem with array

$modules = array( 'home' => 'home', 'login' => 'login', 'forum' => 'forum', 'topic' => 'topic', 'post' => 'post', 'profile' => 'profile', 'moderate' …
1
vote
3answers
233 views

php array in_array oddity…

of all the languages i know im the weakest in php... I have a script... that takes a csv file and does some stuff with it... fairly simple. the issue i am having: in_array('username', $headers) ... …
0
votes
4answers
1k views

PHP in_array not working

Hey everyone, I am using the PHP in_array() function in order to authenticate (with sessions) if a user can access a particular page. For some reason, it is not working... PHP PAGE session_start(); …
4
votes
5answers
987 views

Which is faster: in_array() or a bunch of expressions in PHP?

Is it faster to do the following: if ($var != 'test1' && $var != 'test2' && $var != 'test3' && $var != 'test4') { ... } Or: if (!in_array($var, array('test1', 'test2', …