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';
    }

     

  • 相关阅读:
    动态与静态Include
    java回收算法
    reflection是如何工作的。
    hashcode和equals的约定关系如下
    Java调试器
    混合赋值运算符的使用
    Spring
    Math.?
    oracle--触发器(转)
    oracle --游标详解(转)
  • 原文地址:https://www.cnblogs.com/choucat/p/7152344.html
Copyright © 2011-2022 走看看