PHP implementation of Chinese characters or English according to the first letter search

/** * */ function Getfirstchar ($s 0) { if ($s 0[0]== ' i ' | | $s [0]== ' I ') { return "I"; }elseif ($s 0[0]== ' u ' | | $s [0]== ' u ') { Return ' U '; }elseif ($s 0[0]== ' V ' | | $s [0]== ' V ') {

Calculate distances in PHP based on latitude and longitude

This is a very useful distance calculation function that calculates the distance from location A to B using latitude and longitude. The function can return miles, kilometers, and oceans of three unit types of distance. function

To sort a multidimensional array of PHP

/* Function: The two-dimensional array is sorted by the specified key value $array =array ( 0=>array (' id ' =>8, ' username ' = ' phpernote '), 1=>array (' id ' =>9, ' username ' = ' com '), 2=>array (' id ' =>5, ' username

PHP Web path fetching

Class Httptool { /** *//Get domain name or host address * #测试网址: http://localhost:8081/test/testurl.php?id=5 * Return to localhost:8081 */ Public Function GetHost () { Return $_server[' Http_host '];

PHP remote image gets to local

/* * Remote picture gets to local */ function Grabimage ($url) { if ($url! = "") {//If the picture address is empty $ext = STRRCHR ($url, '. '); Determine the format of a picture if ($ext! = '. jpg ' && $ext! = '. gif '

Check URL, email and IP PHP code

function Is_valid_url ($url) { $p 1 = '/(HTTP|HTTPS|FTP): \/\/[a-z0-9-]+ (. [ a-z0-9-]+) * (: [0-9]+)? (\/.*)? $/i '; Return Preg_match ($p 1, $url); } function Is_valid_email ($email) { if (Filter_var ($email,

Gets the regular expression of a number in a string

!--? php $patterns = "/\d+/";//First type // $patterns = "/\d/"; The second type of $strs = "left:0px;top:202px;width:90px;height:30px"; Preg_match_all ($patterns, $strs, $arr); Print_r ($arr);

How to crawl the email address code in a Web page with PHP

/** Desc: The code that collects the mailboxes in a Web page */ $url = ' http://www.xxx.net '; The URLs to be collected $content =file_get_contents ($url); Echo $content; function Getemail ($STR) { $pattern =

A PHP class for handling cookies

Login Registered Subscribe to RSS Site Map Script Sharing Network Cookieclass Copyright (C) 2005 Jrsofty programming. Http://jrsofty1.stinkbugonline.com Licensed under GNU/GPL Class

PHP quickly get random decimal groups in large arrays

There is a guess the user likes the function, the user can click to change a group, to refresh the recommended content. The First gets the first 1000 data through a database query, and then randomly strips 4. After the program has finished

PHP Graphics Image Processing

Header ("Content-type:image/jpeg"); /* One, simple image output */ $im = Imagecreate (60,40); $pink = Imagecolorallocate ($im, 35, 25,220); Imagejpeg ($im); Imagestring ($im, +,--------);

PHP extracts the main color of any image

function Dominant_color ($image) { $i = Imagecreatefromjpeg ($image); for ($x =0; $x for ($y =0; $y $rgb = Imagecolorat ($i, $x, $y); $r = ($rgb >>) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb

PHP Displays the time as "just" "N Minutes/hour ago", etc.

In many occasions in order to show the timeliness of information, the time is generally displayed as "just", "5 minutes Ago", "3 hours ago", and so on, rather than directly print out the time. such as microblogging, SNS applications for the longest

The PHP code for WHOIS queries

Use the following function to get the full details of any domain user function Whois_query ($domain) { Fix the domain name: $domain = Strtolower (Trim ($domain)); $domain = preg_replace ('/^http:\/\//i ', ' ', $domain)

PHP gets the user's real IP

function Getrealipaddr () { if (!emptyempty ($_server[' http_client_ip ')) { $ip =$_server[' http_client_ip ']; } ElseIf (!emptyempty ($_server[' http_x_forwarded_for ')) To check IP was pass from proxy

PHP returns relative time, such as: 20 minutes ago, 3 days ago

function plural ($num) { if ($num! = 1) return "S"; } function Getrelativetime ($date) { $diff = time ()-Strtotime ($date); if ($diff The return $diff. "Second". Plural ($diff). "Ago";

PHP Digital Operation Verification Code

Getvalidate (100,30); function Getvalidate ($w, $h) { $img = Imagecreate ($w, $h); $gray = Imagecolorallocate ($img, 255,255,255); $black = Imagecolorallocate ($img, Rand (0,200), Rand (0,200), Rand (0,200));

PHP Random Password generator

function Auth_pwgen () { $PW = "; $c = ' bcdfghjklmnprstvwz '; Consonants except hard to speak ones $v = ' Aeiou '; Vowels $a = $c. $v; Both Use the syllables ... for ($i =0; $i $PW. = $c [rand (0,

PHP number converted to Kanji amount

/** * Number converted to Chinese * @param string|integer|float $num target number * @param integer $mode mode [true: Amount (default), false: normal digit representation] * @param boolean $sim use lowercase (default) *

PHP implementation of binary search algorithm

//$low and $high has to be integers function BinarySearch ($array, $key, $low, $high) { if ($low > $high)//T Ermination case { return-1; } $middle = Intval (($low +

Total Pages: 5208 1 .... 4770 4771 4772 4773 4774 .... 5208 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.