PHP函数

PHP函数

标签(空格分隔): PHP


strtr 字符串替换

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 文件遍历

glob() 函数依照 libc glob() 函数使用的规则寻找所有与 pattern 匹配的文件路径,类似于一般 shells 所用的规则一样。不进行缩写扩展或参数替代。

<?php
foreach(glob("*.php") as $list){
    if(is_file($list)) echo $list.'<br/>';
}

输出:
01obj_1.php
02obj_lianshi_capzuo.php
03obj_duotai.php
04and.php

转载于:https://www.cnblogs.com/52fhy/p/4930244.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值