php function

巴扎黑
Release: 2023-03-01 12:28:01
Original
955 people have browsed it

Time related

1.time(), you can get the timestamp of the current time.

2.strtotime(), you can convert a text type datetime into a timestamp.

3. Format output: For example, the output time is 01/31/2011

date('m/d/Y', timestamp).

Another example: date ('Y-m-d H:i:s', timestamp); 2011-01-31 04:20: 59.

Input and output related

echo sprintf("%.2f",0.24236); //Output: 0.24.

Get server host

$request Host = $_SERVER [ 'Http_host'];

$ CurrentPageurl = $ Requesthost. $ _Server ['PHP_SELF']; $ _FILES['photo']['tmp_name']);

img is an array, $img[0], $img[1] represent the width and height of the picture respectively.

img[3] represents the picture Type, related to jpg, gif, png.

files:

Get the suffix name of a file:

array_pop(explode (".",$file));

Array related:

array_push($array,$elem); Append $elem to the back of the array array.

array_merge($array1, $array2); Merge the two arrays into one. Note that if it is an associative array If so, items with the same key will be merged.

shuffle($array); will randomly shuffle the elements in the array.

string related:

explode(",", $ids) ; Convert a comma-separated string into an array.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!