php
听风在笑
毕业于秦皇岛职业技术学院
展开
-
php中urlencode()和urldecode()URL编码函数
URLEncode:是指针对网页url中的中文字符的一种编码转化方式,最常见的就是Baidu、Google等搜索引擎中输入中文查询时候,生成经过Encode过的网页URL。URLEncode的方式一般有两种,一种是传统的基于GB2312的Encode(Baidu、Yisou等使用),另一种是基于UTF-8的Encode(Google、Yahoo等使用)。URLdecode:就是将url编码后的字符串还原成未编码的样子。<?php//GB2312的Encodeecho urlencod转载 2021-08-02 11:56:30 · 1019 阅读 · 0 评论 -
php获取字符串最后一个标点后的字符串和标点前的字符串
$spm ='m-184-191';$result =substr($spm,strripos($spm,"-")+1);echo $result;$url ='admin/auth/index';$result =substr($url,0,strrpos($url,"/"));echo $result;原创 2021-08-02 11:53:49 · 393 阅读 · 0 评论 -
php二维数组排序
array_multisort(array_column($list,'returns_time'),SORT_DESC,$list);原创 2021-07-22 18:47:26 · 102 阅读 · 1 评论 -
phpcms密码加密算法
public function ceshi1(){ $pws = md5(md5(trim("123123"))."iY7KLI"); echo $pws;}原创 2021-06-20 23:19:06 · 371 阅读 · 0 评论 -
php中随机取出数组中不重复的值
function uni($array,$nums,$unique=true){ $newarray=array(); if((bool)$unique){ $array=array_unique($array);// 移除数组中重复的值,并且返回数组。 } if(shuffle($array)){// return bool for ($i=0; $i <count($array) ; $i++) { $newarray[]=$array[$i]; } } r原创 2021-03-26 17:45:53 · 446 阅读 · 0 评论 -
数组去重
<?php/*** 去除数组中重复数据* by www.jbxue.com**/$input = array("a" => "green","", "red","b" => "green", "","blue", "red","c" => "witer","hello","witer");//$result = array_unique($input); //去除重复元素$result = a_array_unique($input); //只留下单一元素fore原创 2021-03-11 15:08:24 · 84 阅读 · 0 评论 -
tp6数据库中保存的html代码被原样输出了,浏览器没有解析
解决办法:{$html|raw}原创 2021-01-10 15:22:13 · 949 阅读 · 0 评论 -
p6关联查询字段设置问题及层次关系
关联模型代码如下: public function profile() { return $this->hasOne(SubscribeCategory::class, 'id', 'cid'); }控制器查询public function getMySubscribe($uid){ $users = Subscribed::with('profile')->where('uid', $uid)->field('subscribe_i原创 2020-12-08 19:28:54 · 170 阅读 · 0 评论 -
php 获取两个一维数组之间不同的值
$a = [1,2,3];$b = [2,3,7,1,5];$arr3 = array_merge(array_diff($a,$b),array_diff($b,$a));原创 2020-12-08 17:55:15 · 587 阅读 · 0 评论 -
php array_chunk
定义和用法array_chunk() 函数把一个数组分割为新的数组块。语法array_chunk(array,size,preserve_keys);array 必需。规定要使用的数组。size 必需。一个整数,规定每个新数组块包含多少个元素。preserve_key 可选。可能的值:true - 保留原始数组中的键名。false - 默认。每个新数组块使用从零开始的索引。...原创 2020-12-08 11:44:45 · 104 阅读 · 0 评论 -
PHP ASCII 与中文字符串转换(只能中文字符串)
中文字符串转ASCIIpublic function strtoascii($str){ $str=mb_convert_encoding($str,'GB2312'); $change_after=''; for($i=0;$i<strlen($str);$i++){ $temp_str=dechex(ord($str[$i])); $change_after.=$temp_str[1].$temp_s原创 2020-10-29 10:56:12 · 399 阅读 · 0 评论 -
php基于数组的分页实现
关于数组的分页函数,用数组进行分页的好处是可以方便的进行联合多表查询,只需要将查询的结果放在数组中就可以了以下是数组分页的函数,函数page_array用于数组的分页,函数show_array用于分页函数的操作及显示,需要配合使用.两个函数通过全局变量$countpage发生联系,此变量用于跟踪总页码数.<?php /** * 数组分页函数 核心函数 array_slice * 用此函数之前要先将数据库里面的所有数据按一定的顺序查询出来存入数组中 * $count 每页多少条数据原创 2020-05-28 13:52:34 · 363 阅读 · 0 评论 -
php 数组排序方法-根据指定的键对多维数组进行排序
根据指定的键对多维数组排序,可以按照多个键排序我们通常有一些多维数组需要排序:$guys = array( array( 'name' => 'jake', 'score' => 80, 'grade' => 'A' ), array( 'name' => 'jin', 'score' => 70, 'grade' => 'A' ),原创 2020-05-10 15:59:29 · 242 阅读 · 0 评论