PHP中常用函数的使用说明
1.重复一个字符串或者符号多少次
str_repeat("=", 3)
结果 ‘===’
2.随机抽出1个或者多个key
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
array_rand($res,1);
结果 ‘c’
3.返回二维数组的一列,重新组成一个一维数组
$a=array( ['a'=>1,'b'=>2], ['a'=>3,'b'=>4], ['a'=>5,'b'=>6]);
array_column($a, 'b')
结果 一维数组[2,4,6]
3.获取files文件 图片长宽
$img_info = getimagesize($_FILES['urlPic']['tmp_name']);
$img_bili = $img_info[0]/$img_info[1]; //判断图片比例 图片宽除以高
4.把整个文件读入一个数组中
file($_FILES['url']['tmp_name']);
5.截取、查找字符串
截取字符串中最后一个标记后的字符串 如 1.0.1.300
strrchr("1.0.1.300", ".") 从某个字符串从最后出现的位置截取到结尾 结果 0.300
substr(strrchr("1.0.1.300", "."), 1) //从指定位置开始截取字符串,可以指定截取的长度 结果 300
strstr("1.0.1.300", ".") = strchr(,) //从前面第一次出现某个字符串的地方截取到最后 结果 .0.1.300
strpos("1.0.1.300", ".") //某个字符串第一次出现的位置 下标从0开始 结果 1
strrpos("1.0.1.300", ".") //某个字符串最后一次出现的位置 下标从0开始 结果 5
6.保留小数点后几位有效数的函数 千位分组来格式化数字
number_format("10000",2) 结果1,0000.00

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
