• php日常应用函数


    php 重要函数
    compact 创建一个包含变量名和它们的值的数组:
    value($arr,'select_value') 获取arr中已select_value 为索引的数值
    debug_backtrace() 函数生成 backtrace(回溯跟踪)。
    get_included_files() 包含的文件列表 https://zhidao.baidu.com/question/431632253.html
    array_change_key_case() 函数 将数组的所有的键转换为大写字母
    getchwd() 函数返回当前工作目录
    filemtime() 函数返回文件内容上次的修改时间
    array_change_key_case() 函数将数组的所有的键都转换为大写字母或小写字母
    php_strip_whitespace() 函数返回已删除 PHP 注释以及空白字符的源代码文件。
    parse_str() 函数把查询字符串解析到变量中。
    array_walk_recursive() 函数对数组中的每个元素应用用户自定义函数
    number_format() 去除逗号的方法 【number_format($num,2,'.',''); // 使用第四个参数,设置逗号格式为空】
    3)替换:
    substr_replace($str,'替换值',$start,$end); 替换指定位置的的字符串中为指定 【替换值】
    str_replace($find,$replace,$str,$count); 以其他字符串中的字符替换 str 中的指定字符
    str_ireplace() 【同上,不区分大小写】
     
     
    glob() 函数返回匹配指定模式的文件名或目录
    例:print_r(glob("*.txt"));
    Array
    (
    [0] => target.txt
    [1] => source.txt
    [2] => test.txt
    [3] => test2.txt
    )
     
     
     
    each($arr);将返回数组当前元素的一个键名/值的构造数组,并使数组指针向前移动一位
    list($key,$value)=each($arr);获得数组当前元素的键名和值
     
    数组转为字符串及字符串转为数组
    explode('/',$str)     以'/'分割字符串,并将其转为数组
    implode('/',$arr)     以'/'为连接符,并转为字符串
     
    数组和变量之间的转换
    extract($arr);     用于把数组中的元素转换成变量导入到当前文件中,键名当作变量名,值作为变量值
    注:(第二个参数很重要,可以看手册使用)使用方法 echo $a;
    compact(var1,var2,var3);     用给定的变量名创建一个数组

  • 相关阅读:
    [CodeForces]Codeforces Round #429 (Div. 2) ABC(待补)
    About Me
    2018-06-14
    Codeforces Codeforces Round #484 (Div. 2) E. Billiard
    Codeforces Codeforces Round #484 (Div. 2) D. Shark
    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
    Codeforces Avito Code Challenge 2018 D. Bookshelves
    Codeforces Round #485 (Div. 2) D. Fair
    Codeforces Round #485 (Div. 2) F. AND Graph
  • 原文地址:https://www.cnblogs.com/sien6/p/13780819.html
Copyright © 2020-2023  润新知