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

PHP数组的使用和遍历

 1、数组的申请和使用:
$array=array(array(2,324,34)); 
echo   $array[0][1]; 
直接申请使用:
$student[0][0]="我";
$student[0][1]="是";
$student[1][0]="谁";
$student[1][1]="维";
 echo   $student[1][0];
2、遍历:
foreach()是一个用来遍历数组中数据的最简单有效的方法。
 
<?php
$colors = array('red','blue','green','yellow');
foreach ($colors as $color) {
echo "Do you like $color? <br />";
}
?>
 
显示结果:
Do you like red?
Do you like blue?
Do you like green?
Do you like yellow?
 
 
 
2. while()
while() 通常和 list(),each()配合使用。
#example2:
 
<?php
$colors = array('red','blue','green','yellow');

while(list($key,$val) = each($colors)) {
echo "Other list of $val.<br />";
}
?>
显示结果:
Other list of red.
Other list of blue.
Other list of green.
Other list of yellow.
 
 
 
3. for()
#example3:
 
<?php
$arr = array ("0" => "zero","1" => "one","2" => "two");

for ($i = 0;$i < count($arr); $i++) {
$str = $arr[$i];
echo "the number is $str.<br />";
}
?>
显示结果:
the number is zero.
the number is one.
the number is two.
 
 
 
========= 以下是函数介绍 ==========
key()
mixed key(array input_array)
key()函数返回input_array中位于当前指针位置的键元素。
#example4
下载: list_array04.php
 
<?php
$capitals = array("Ohio" => "Columbus","Towa" => "Des Moines","Arizona" => "Phoenix");
echo "<p>Can you name the capitals of these states?</p>";
while($key = key($capitals)) {
echo $key."<br />";
next($capitals);
//每个key()调用不会推进指针。为此要使用next()函数
}
?>
显示结果:
Can you name the capitals of these


相关文档:

php学习笔记

 1、$_SERVER['SCRIPT_NAME']、$_SERVER['PHP_SELF']和$_SERVER['REQUEST_URI']区别
例子:http://localhost/phpwind75/test.php/%22%3E%3Cscript%3Ealert(’xss’)%3C/script%3E%3Cfoo
$_SERVER['SCRIPT_NAME']只获取脚本名,不获取参数,输出结果为:test.php;
$_SERVER['PHP_SELF']获取脚本名后,同时获� ......

PHP 压缩文件夹的类!

 <?php
/*
  $Id: PHPZip.php
*/
class PHPZip {
  var $datasec      = array();
  var $ctrl_dir     = array();
  var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
  var $old_offset   = 0;
& ......

linux下查看nginx,apache,mysql,php的编译参数

有时候nginx,apache,mysql,php编译完了想看看编译参数可以用以下方法
nginx编译参数:
#/usr/local/nginx/sbin/nginx -V
CODE:
nginx version: nginx/0.6.32
built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42)
configure arguments: --user=www --group=www --prefix=/usr/local/nginx/ --with-http_stub_status_mo ......

php 创建和删除文件夹

//创建文件夹的方法
//$path 为文件夹参数,如 (c:/program files/makedir)
 function createFolders($path) {
    if (!file_exists($path)) {
      $this->createFolders(dirname($path));
      mkdir($path, 0777);
  &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号