相当与ASP中的instr()函数 (s…
来源:互联网 发布:c语言逻辑符号优先级 编辑:程序博客网 时间:2024/04/29 03:05
PHP判断字符串的包含代码如下:
1、strpos()stripos()
instr(rs("manage"),"12")>0 then
strpos($me,"15")!=false)
strpos() 函数 该函数对大小写敏感
stripos() 函数 该函数对大小写不敏感。
<?php
echo stripos("Hello world!","WO");
?>
输出:6
2、explode()
4. 用explode进行判断
PHP判断字符串的包含代码如下:
- function checkstr($str){
- $needle = "a";//判断是否包含a这个字符
- $tmparray = explode($needle,$str);
- if(count($tmparray)>1){
- return true;
- } else{
- return false;
- }
- }
3、in_array()检查数组中是否存在某个值
in_array -- 检查数组中是否存在某个值
例子 1.
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
}
if (in_array("mac", $os)) {
}
?>
第二个条件失败,因为
Got Irix
例子 2.
<?php
$a = array('1.10', 12.4, 1.13);
if (in_array('12.4', $a, true)) {
}
if (in_array(1.13, $a, true)) {
}
?>
上例将输出:
1.13 found with strict check
例子 3.
<?php
$a = array(array('p', 'h'), array('p', 'r'), 'o');
if (in_array(array('p', 'h'), $a)) {
}
if (in_array(array('f', 'i'), $a)) {
}
if (in_array('o', $a)) {
}
?>
上例将输出:
'ph' was found 'o' was found
=================================
array_search -- 在数组中搜索给定的值,如果成功则返回相应的键名
说明
mixed
在
注:
如果 needle 是字符串,则比较以区分大小写的方式进行。
注:
在 PHP 4.2.0之前,array_search() 在失败时返回 NULL 而不是 FALSE。
如果可选的第三个参数
如果
例子 1.
<?php
$array = array(0 => 'blue', 1 =>'red', 2 => 'green', 3 =>'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red',$array);
?>
- 相当与ASP中的instr()函数 (s…
- InStr() asp中的函数
- asp中的InStr函数的改写
- Oracle中的instr函数
- oracle 中的 instr 函数
- Oracle中的函数instr函数
- Oracle函数substr与instr
- ASP判断是否包含字符串(InStr 函数)
- Oracle中的instr函数的用法
- oracle中的instr和substr函数
- Oracle中的instr和substr函数用法
- Oracle数据库中的instr函数的用法
- MATLAB中的eye() 函数 …
- Oracle中的空字符串与instr
- InStr函数
- Instr函数
- instr函数
- InStr 函数
- Hive之——启动问题及解决方案
- 字符串转成日期的函数
- 从mysql导出到excel 格式为.csv
- 从mysql导出到excel 格式为.xls
- asp函数split()对应php函数explode…
- 相当与ASP中的instr()函数 (s…
- PHP上传文件代码
- excel导入mysql(用PHP-ExcelReader…
- postgresql in 优化
- phpMyAdmin mysql 如何…
- 同时取得GET和POST的值
- PHP数组对比,存在交集则返回真,…
- PHP 时间函数:与当前时间比…
- 【Android新手笔记二】日期对话框