易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

asp,asp.net,php,jsp下的301转向代码,整站重定向

 asp,asp.net,php,jsp下的301转向代码
使用.htaccess文件来进行301重定向。
如果空间不支持.htaccess文件,那么我们还可以通过php/asp代码来进行301重定向。
为了将搜索引擎的记录更新到现在的域名上面,做了几个301重定向的东东,给大家分享一下.
asp 301转向代码
在 index.asp 或 default.asp 的最顶部加入以 ......

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;
& ......

php 创建和删除文件夹

//创建文件夹的方法
//$path 为文件夹参数,如 (c:/program files/makedir)
 function createFolders($path) {
    if (!file_exists($path)) {
      $this->createFolders(dirname($path));
      mkdir($path, 0777);
  &n ......

PHP Security for Deployers

PHP Security for Deployers
If you're a Developer
READ THIS and then work with your SysAdmins to step through any and all the layers of security designed to protect your apps.
Example:
Traffic must first pass through a SPI firewall (ensure that ONLY necessary ports/protocols are permitted; en ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号