PHP代码篇(七)--PHP及MySQL已经使用过的函数

一、PHP常用函数

//数组转字符串
$str = implode(',',$device_string);

//字符串转数组
$arr = explode(',',$device_string);

//按照RFC 3986 对 URL 进行编码
$str = rawurlencode( $str );

// 对已编码的 URL 字符串进行解码
$str = rawurldecode ( $str );

//字符串替换
$content = str_replace("<img src=","",$content);

//删除字符串末端的','字符
$content = rtrim($content,",");

//在数组开头插入一个或多个单元
array_unshift($queue, "apple", "raspberry");

//保留两位小数不进行四舍五入,$num=3.149,结果3.14
$new_num = floor($num*100)/100;

//四舍五入,$n = 3.14899,结果3.15
$new_num = round($n,2);

二、MySQL常用操作

//保留两位,舍去末尾,结果 = 100.34
SELECT TRUNCATE(100.3465,2)

猜你喜欢

转载自www.cnblogs.com/camg/p/11635135.html