易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP函数(2)

in_array(value,array,type)        //检查一个值是否在数组中,type可选,设置为true检查类型是否相同,分大小写
例:
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}

第二个条件失败,因为 in_array() 是区分大小写的,所以以上程序显示为:
Got Irix

in_array() 严格类型检查例子
$a = array('1.10', 12.4, 1.13);
if (in_array('12.4', $a, true)) {
echo "'12.4' found with strict check\n";
}
if (in_array(1.13, $a, true)) {
echo "1.13 found with strict check\n";
}

上例将输出:
1.13 found with strict check

in_array() 中用数组作为 needle
$a = array(array('p', 'h'), array('p', 'r'), 'o');
if (in_array(array('p', 'h'), $a)) {
echo "'ph' was found\n";
}
if (in_array(array('f', 'i'), $a)) {
echo "'fi' was found\n";
}
if (in_array('o', $a)) {
echo "'o' was found\n";
}
上例将输出:
'ph' was found
'o' was found



相关文档:

PHP中stripslashes和addslashes的使用

向mysql写入数据时,如:mysql_query("update tableName set `title`='goaler's blog'");
  这个时候,PHP将会报错,ASP中处理时也一样。
  因为数据库对单引号过敏。
  ASP中需要进行replace("'","''",str);
  而PHP中则可以直接使用addslashes。
  ASP问题这里暂不考虑,本文要说的是PHP相关的strip ......

php 字符串安全过滤 全攻略

<?php
if (!get_magic_quotes_gpc()) {
add_slashes($_GET);
add_slashes($_POST);
add_slashes($_COOKIE);
}

function add_slashes($string) {
if (is_array($string)) {
foreach ($string as $key => $value) {
$string ......

php遍历整个目录的文件以及文件夹

最近去面试PHP程序员 出了一道这样的题 “php遍历整个目录的文件以及文件夹 封装成函数”顺便也就贴了上来。需要的朋友可以拿去用用,仅供学习交流使用。如有不恰当的地方还请各位高手“嘴下留人” 啊!
<?php
$path=$_SERVER["DOCUMENT_ROOT"];
$path=str_replace("/","\\",$path);
$path="$ ......

PHP数组函数使用方法详解

1.array_multisort()对多个数组或多维数组进行排序可以用来一次对多个数组进行排序或者根据某一维对多维数组进行排序。排序时保留原有的键名关联,实现的功能和SQL中的ORDERBY差不多。
$ar1=array("10",100,100,"a"); $ar2=array(1,3,"2",1); array_multisort($ar1,$ar2); ?> //返回结果(保持了原来数组的关联性) ......

Linux中安装PHP 5教程

第一步 安装MySQL
[root@localhost usr]# groupadd mysql
[root@localhost usr]# useradd -g mysql mysql
[root@localhost usr]# cd /usr/local
[root@localhost local]# tar -zxvf mysql-5.0.51.tar.gz
[root@localhost local]# cd mysql-5.0.51
[root@localhost mysql-5.0.51# ./configure --prefix=/usr/local/my ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号