zoukankan      html  css  js  c++  java
  • 20170322、php基础语法

    (1)时间戳

    date_default_timezone_set("Asia/Shanghai"); //时区

    $time = date('Y-m-d H:i:s'); echo strtotime($time);//转时间戳

    $date = date('Y-m-d H:i:s', strtotime($time));//时间格式

    (2)数组转字符串&&字符串转数组

    $arr = "[1,2,6,4,6,7,9,11,12,14,15,16]";
    $abc = json_decode($arr, true);//json转数组
    $ids = implode(",", $abc);//数组转字符串

    $array = array('test', '测试', 'test1', 'test2');
    echo "'" . implode("','", $array) . "'";

    (3)截取字符串

    $str_bh='123456789';
    $abc=substr($str_bh,-8);

    (4)序列化&&反序列化

    $spec_arr = unserialize('');

    (5)字符串去所有空格

    str = "a b c d ";
    $qian = array(" ", " ", "\t", "\n", "\r");
    $hou = array("", "", "", "", "");
    $array = explode(",", str_replace($qian, $hou, $str));
    echo '"' . implode('","', $array) . '"';

    (6)数组&&多维

    unset($classify_arr['classify'][$k]);//移除数组中一条记录

    if (in_array('手机类型', $v)) {//检查数组中存在某个值
        echo 'cunzai';
    }

     

  • 相关阅读:
    图书排列
    L1-059 敲笨钟 (20 分)
    区间移位
    取球博弈
    poj 2456 Aggressive cows
    对局匹配
    发现环
    数字划分
    哥德巴赫分解
    把数组排成最小的数
  • 原文地址:https://www.cnblogs.com/choucat/p/7152344.html
Copyright © 2011-2022 走看看