Some of the features of PHP functions you may not know

Source: Internet
Author: User

This article describes these functions you probably know, have used, but there are some small points you may not notice, and the development will also use these points, when you use, you can think of these PHP function features, then you not only development efficiency, and code quality is high. Here I'll show you some of these functions:

Array_diff: Compare value only, and the key value remains the same.

ARRAY_DIFF_ASSOC: not only compares value, but also compares the key value, and the result key value is reordered

Array_diff_key ($array 1, $array 2, $array 3 ...) : includes all values that appear in the array1 but do not appear in any other parameter array, and in the last parameter you can also customize a function

strip_tags ($str, ' <p> '): strip HTML tags, but keep img and p tags

In_array (): The function adds a true to the third parameter to avoid data format conversions to improve performance.

str_replace (Array (' 1 ', ' 2 '), Array (' A ', ' B '), $STR):both Str_replace and Preg_match can be passed as an array

Array_slice (array,offset,length, Preserve): The fourth argument retains the key name if true, otherwise the index is sorted from the new one

Array_search (value,array):php return key, PHP gives a value, return the array corresponding to the value of the key, return only one, will not continue to look down

Array_keys: also returns a key value, but if more than one key value is returned

@mkdir ($dir, 0777,true): The third value is true to recursively create a directory

The functions and methods in PHP are mutable (for frames).     $a (); $obj $a ();


Some of the features of PHP functions you may not know

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.