English 中文(简体)
php 中的 php 忽略大小写
原标题:ignore case in php
  • 时间:2012-05-23 15:51:54
  •  标签:
  • php
  • arrays

i 正在从正在获取数据库值的数组中, 使用 in_ array () 函数搜索文本 。

美元值是数组值。

我怎么能忽略这个案子呢?

if(in_array($exp[$i],$value))
最佳回答

使用 < a href=> "http://php.net/manual/en/formation.preg-grep.php" rel = "nofollow" > preg_grep () 代替:

if( preg_grep( "/" . $exp [$i] . "/i" , $value ) )

(在 / 之后添加了 / 修饰符,使其不敏感)

然而,由于它似乎不是一个数组值,你不应该使用in_arry() ,但stristr() :

if ( stristr ($value, $exp [$i]))

(' rel="nofollow">stristr () 的不敏感版本“http://php.net/manual/en/form.str.php” rel=“nofollow”>strstr () ,其中发现在另一字符串中首次出现字符串)

问题回答

在比较中将其转换为所有上/下大小写

if(in_array($exp[$i], strtoupper($value)))

我猜这美元[美元]也需是不可知的,所以

if(in_array(strtoupper($exp[$i]), strtoupper($value)))




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签