记两个PHP函数

记两个PHP函数

fileicq81.gif

http://cn.php.net/manual/zh/function.file.php

<?php
// 将一个文件读入数组。本例中通过 HTTP 从 URL 中取得 HTML 源文件。
$lines 
=  file('http://www.example.com/') ;
// 在数组中循环,显示 HTML 的源文件并加上行号。
foreach ($lines as $line_num 
= > $line) {
   echo 
" Line #<b>{$line_num}</b> :  "  . htmlspecialchars($line) .  " <br />\n " ;
}
// 另一个例子将 web 页面读入字符串。参见 file_get_contents()。
$html 
=  implode('' ,  file ('http://www.example.com/')) ;
?> 

正则表达式 查找替换
http://cn.php.net/manual/zh/function.preg-replace.php

<?php
$string 
=   " April 15, 2003 " ;
$pattern  =   " /(\w+) (\d+), (\d+)/i " ;
$replacement  =   " \${1}1,\$3 " ;
print preg_replace($pattern ,  $replacement ,  $string) ;

/* Output
   
======

April1
, 2003

 */
?> 

你可能感兴趣的:(记两个PHP函数)