PHP日常实用小Tips

字体大小: 中小 标准 ->行高大小: 标准

header("Content-Type: audio/mpeg");

header("Location:ftp://download:1bk3l4s3k9s2@218.30.116.103/1001/咖哩辣椒/咖喱辣椒.rmvb");
.......2004-10-08 13:26:45
8.替换所有的字符为*
$a="~!@#$%^&*./=-";
echo preg_replace("/./","*",$a);
用perl的正则替换,方便
9.正则匹配中文
ereg("^[".chr(0xa1)."-".chr(0xff)."]+$", $str);
10.批量替换文本里面的超级链接
<?php
function urlParse($str = '')
{
if ('' == $str) return $str;

$types = array("http", "ftp", "https");

$replace = <<<EOPHP
'<a href="'.htmlentities('\1').htmlentities('\2').'">'.htmlentities('\1').htmlentities('\2').'</a>'
EOPHP;

$ret = $str;

while(list(,$type) = each($types))
{
$ret = preg_replace("|($type://)([^\s]*)|ie ", $replace, $ret);
}

return $ret;
}
?>

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/600.html