PHP 中 in_array 函数的用法与注意项
in_array(value,array,type)
in_array 作用是用于查看 value 是否在 array 中存在,如果参数 value 是字符串,且 type 参数设置为 true,则搜索区分大小写。则 in_array 是 区分大小写 的。
有一点需要注意,当 array 中包含 value 的值,则返回 true; 但是,如果两者参数之间相等,则返回 false
例如:
$str = 'a';
$arr = array('a','b','c');
if( in_array($str,$arr) ){
echo "包含..";
}else{
echo '不包含..';
}
上面的代码运行后返回 “包含” 也就是 true,因为 $str 中有 $arr 的值、大小写也一样,最重要的是两者参数不相等!
再来,我们换个代码。
$str = array('a','b','c');
$arr = array('a','b','c');
if( in_array($str,$arr) ){
echo "包含..";
}else{
echo '不包含..';
}
这次就返回不包含了,所以我只能理解为 只能 $arr 中包含 $str,不能相等或超越。
那么修改下。
$str = array('a','b','c');
$arr = array(
array('a','b','c'),
array('d','e','f')
);
if( in_array($str,$arr) ){
echo "包含..";
}else{
echo '不包含..';
}
新手笔记,经供参考,如果错误,请指正!
相关文档:
#apt-get install apache2
//安装apahce2
#apt-get install php5
//安装php5
#apt-get install mysql-server
//安装mysql服务端
#apt-get install mysql-myclient
//安装mysql的客户端
#apt-get install php-mysql
//安装php-mysql的连结
apache+php+mysql 环境已经搭建好了
将以下的服务重启一下
#/et ......
Guoqzhang_PHP 简易php framework 请多指点。
Guoqzhang_PHP V 1.0 的PHP开发框架,采用MVC设计模式,运用Smarty模板引擎术和MySQL数据库技术开发而成。
设计到开发完成耗时20个工作日左右,时间短,可能存在一些bug,请大家指正.作者mail:guoqzhang@gmail.com
url:http://download.csdn ......
<div id="time" align="center">time </div>
<script language="javascript">
function time1()
{
var now,n,y,r,h,m,s;
now=new Date();
n = now.getYear();
y = now.getMonth()+1;
r = now.getDate();
h = now.getHours();
m =now.getMinutes();
s = now.getSeconds();
......
php中substr的用法详解
php.net中关于substr的说明很简单:
start
If start is non-negative, the returned string will start at the start 'th position in string , counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so for ......
<?php
/*
* Created on 2009-10-28
* 分子如梦o(╯□╰)o
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
interface pusb{
function verson();
  ......