@52fhy
2016-02-28T02:12:03.000000Z
字数 562
阅读 560
PHP
string strtr ( string $str , string $from , string $to )string strtr ( string $str , array $replace_pairs )
对指定字符串$str将里面的$from替换为$to。
参数 replace_pairs 可以用来取代 to 和 from 参数,因为它是以 array('from' => 'to', ...) 格式出现的数组。
<?php$trans = array( "hello" => "hi" , "hi" => "hello" );echo strtr ( "hi all, I said hello" , $trans );?>
以上例程会输出:
hello all, I said hi
glob() 函数依照 libc glob() 函数使用的规则寻找所有与 pattern 匹配的文件路径,类似于一般 shells 所用的规则一样。不进行缩写扩展或参数替代。
<?phpforeach(glob("*.php") as $list){if(is_file($list)) echo $list.'<br/>';}
输出:
01obj_1.php
02obj_lianshi_capzuo.php
03obj_duotai.php
04and.php
