php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27225 in_var function
Submitted: 2004-02-11 17:10 UTC Modified: 2004-02-11 17:35 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: chris dot walsh at pni dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.5RC2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chris dot walsh at pni dot com
New email:
PHP Version: OS:

 

 [2004-02-11 17:10 UTC] chris dot walsh at pni dot com
Description:
------------
Looking for a comparison operator/function to similar to the mysql "in" function.

This could be used to replace long if statments:
if($a=="b" || $a=="c" || $a=="d")

something like
if(in($a,"b","c","d"))
or
if($a=="b"||"c"||"d")
or
if($a|="b","c","d")



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-11 17:30 UTC] derick@php.net
if (in_array("a", array("a", "b", "c"))) works fine for this :)
 [2004-02-11 17:35 UTC] chris dot walsh at pni dot com
That works... as does an ereg() call, but it seems kind of clunky to have to create an array and then call an array function (or use a pattern match), when it would be more efficient to have a function/operator that deals directly with the string.

Just my two cents...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 23:01:27 2024 UTC