Php retrieves the first image of an article.

First, let's look at a function: The code is as follows:Copy code Function getpic ($ str_img ){Preg_match_all ("//isU", $ str, $ ereg); // the regular expression retrieves the entire image.$ Img = $ ereg [0] [0]; // Picture$ P = "# src = ('|") (.

PHP bubble sorting algorithm example

Example 1 The code is as follows:Copy code /*** Bubble sorting (one-dimensional array)* Compare the size of the elements to be sorted. If the two data elements are in the opposite order, they are exchanged until there is no data element in the

Php file upload code

The following php file Upload class is mainly used to upload files, including images, videos, and Word documents. In fact, it is recommended to process images. The main reason for recommendation is that this class is very standard, basically, all

PHP character truncation function, compatible with various gbk and UTF-8 encoding

Example 1 The code is as follows:Copy code Function CsubStrPro ($ str, $ start, $ length, $ charset = "UTF-8", $ suffix = false){If (function_exists ("mb_substr "))Return mb_substr ($ str, $ start, $ length, $ charset );$ Re ['utf-8'] = "/[x01-x7

Php array_flip () and array_uniqure () delete repeated array elements

The method is as follows: The code is as follows:Copy code $ Arr = array (............) ; // Assume that an array contains 10 thousand elements with repeated elements. $ Arr = array_flip ($ arr); // you can delete duplicate elements.  What is

PHP obtains the location instance of an element in the array.

The syntax of array_keys is as follows:Array_keys (array, value, [strict])When strict is set to true, the strict matching mode of data type verification is triggered. The default value is false. The following code shows a simple application of array_

A collection of email address verification in php

CodeIgniter framework Email Address Verification The code is as follows:Copy code /*** Valid Email     * * @ Access public* @ Param string* @ Return bool*/Function valid_email ($ str)    { Return (! Preg_match ("/^ ([a-z0-9 + _-] + )(. [a-z0-9 +

PHP obtains the real address instance to jump.

Get Response Headers, and then analyze it slowly.Specific Implementation methods are provided: The code is as follows:Copy code $ Header = get_headers ($ url, 1 );If (strpos ($ header [0], '2017 & prime;) | strpos ($ header [0], '2017 & prime ;))

Php converts IP addresses to integer instances

[Conversion principle]: assume that the IP address is w. x. y. z, the formula for converting the IP address to an integer is: intIP = 256*256*256 * w + 256*256 * x + 256 * y + z[PHP conversion]: the PHP conversion method is relatively simple. It has

Php injection 1

This article mainly serves the dishes. If you are an old bird, some things may be boring, but as long as you read it carefully, you will find a lot of interesting things.To read this article, you only need to understand the following.1. understand

Implement object-oriented programming in PHP (II)

PolymorphismPolymorphism is defined as the ability of an object to call a method when it is passed as a parameter at runtime. For example, if you use a class to define the method "draw" and inherit the class to redefine the behavior of "draw" to

PHP + Javascript LCD clock

$ Size_small = 5; // LCD width$ Size_big = 25; // LCD length$ Distance = 10; // spacing$ Color_back = "# DDDDDD ";$ Color_dark = "# CCCCCC ";$ Color_light = "#000000 ";$ Number = 0;?> Timer //************************************** *******************

Example of Chinese and English string length truncation in php

Before using this method, enable the php_mbstring.dll extension in php. ini and remove the semicolon before extension.Many methods to intercept Chinese strings do not support the number of Chinese characters,The following code can be implemented:

Php recursive method to implement unlimited classification instances

Array: The code is as follows:Copy code $ Items = array (Array ('id' => 1, 'pid '=> 0, 'name' => 'Level 1 11 '),Array ('id' => 11, 'pid '=> 0, 'name' => 'Level 1 12 '),Array ('id' => 2, 'pid '=> 1, 'name' => 'Level 2 21 '),Array ('id' => 10,

How to sort a PHP two-dimensional array by a field?

Let's look at the two-dimensional array sort instances by a field. The code is as follows:Copy code /*** @ Author yebihai http://www.111cn.net* @ Desc sort by a field in a two-dimensional array.* @ Data* $ TestData = array (Array ('price' => 19 )

PHP uses curl to obtain the verification code (sending a cookie for secondary capture)

The code is as follows:Copy code $ CookieFile = tempnam ("./tmep", "beast ");If (isset ($ _ GET ["img"]) {$ Url = 'http: // www.111cn.net/phper/php.htm'#//verification code$ Ch = curl_init ($ url );Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $

Php + jquery ajax email address without refreshing verification instance

Index. php page The code is as follows:Copy code php jquery check username ajax check account uniqueness Username: Php verification page, which receives data from jquery ajax post for verification and returns the value The code is as follows:

Php CURL simulates login to the Forum and collects data instances

To simulate browser access to a website, you should first learn how the browser sends http packets and what content the website server returns to the browser. I recommend installing an httpwatch software developed by a foreign user. It is best to

PHP two-dimensional array deduplication custom function

Example 1 The code is as follows:Copy code Function unique_array_2d ($ array2D, $ stkeep = false, $ ndformat = true){// Determine whether the primary array key is retained (the primary array key can be non-numeric)If ($ stkeep) $ stArr =

Total Pages: 12780 1 .... 10637 10638 10639 10640 10641 .... 12780 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.