Oct 29

php code snippit 不指定

felix021 @ 2015-10-29 10:51 [IT » 程序设计] 评论(0) , 引用(0) , 阅读(9548) | Via 本站原创 | |
转置二维数组:
function transpose($array) {
    array_unshift($array, null);
    return call_user_func_array('array_map', $array);
}


utf-8字符串转为utf-8字符数组:
function utf8_str2arr($str)
{
    preg_match_all("/./u", $str, $arr);
    return $arr[0];
}


按显示宽度截取utf-8字符串
function substr_width($str, $start, $width)
{
    $arr = utf8_str2arr($str);
    $arr_ret = [];
    $i = 0;
    while ($width > 0 and $i < count($arr))
    {
        $arr_ret[] = $arr[$start + $i];
        if (strlen($arr_ret[$i]) == 1) //ascii,width=1
            $width -= 1;
        else
            $width -= 2;
        $i++;
    }
    if ($width < 0)
        array_pop($arr_ret);
    return join('', $arr_ret);
}


让进程在后台运行(detached process),出乎意料地简单
pclose(popen("nohup $cmd &", 'r'));




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]