天空是蓝色的

做好软件为中国 #gcc -c helloworld.c -o helloworld.o //编译目标文件 #gcc helloworld.o -o helloworld //编译成可执行exe #helloworld //运行exe
数据加载中……
记两个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

 */
?> 

posted on 2005-12-27 22:45 bluesky 阅读(412) 评论(0)  编辑  收藏 所属分类: PHP


只有注册用户登录后才能发表评论。


网站导航: