The arrangement of elements function of PHP array

Source: Internet
Author: User
Tags local time shuffle unique id

collation of PHP array elements

1.Count () calculates the number of elements in the array;

2.array_values (array $input) returns all the arrays in the array as an indexed array.

the value of the element only one array parameter is required, and the associative array is transformed into a digital index array;

3.array_keys (array$array[,mixed$search_value[,bool$strict=false]] returns the array

Partial or all key names, two-dimensional arrays show only first-level key names

4.in_array (mixed$needle,array$haystack[,bool$strict=false]) Find a specific element

Array_search () also has the same effect

6.array_reverse (array$array[,bool$preserve_keys=false]) reverses the array

If set to TRUE retains the key of the Number. Non-numeric keys are not affected by this setting

will always be preserved.

7.array_unique (array$array[,int$sort_flags=sort_string]) Delete duplicate in array

The value

8.Array array_slice (Array $array, int$offset[,int$length=null[,bool$preserve_

Keys=false]]) Returns a value in an array based on a condition, if offset is nonnegative , the sequence

starts at this offset in the array. If offset is negative, the sequence will be distance from the array

the micro-end was so far away that the place Began. If length is given and is positive, the sequence will have

so many Units. If length is given and is negative, then the sequence terminates in the distance array

end so far from the Place. If omitted, the sequence starts at offset from the end of the Array.

9.Array array_splice (array& $input, int$offset[,int$length=0[,mixed

$replacement]]) Delete Some of the values in the array according to the criteria (you can specify some values to override the deleted values);

10.Array Array_combine (array$keys,array$values) creates an array with the values of an array

As its key name, the value of the other array as its value;

11.Array array_merge (array$array1[,array$ ...) combine one or more arrays into an array

12.Array array_intersect (array$array1,array$array2[,array$ ...) returned in multiple arrays

Recurring Values (array Intersection)

13.Array Array_diff (array$array1,array$array2[,array$ ...]) returns the difference set of an array

14.Array Array_map (callable$callback,array$arr1[,array$ ...]) Functions the callback function to a specific

Words on the group

15.array_shift () Delete the first element of an array

16.array_unshift () Inserts one or more cells at the beginning of the array

17.array_push () Presses one or more cells into the end of the array ( into the stack );

18.array_pop () pops the last cell of the array

19.Mixed array_rand (array$input[,int$num_req=1]) randomly returns one or more elements of an array

A key name that indicates how many units you want to Remove. If the specified number exceeds the number in the array, it will

produce a E_warning level of Error.

20.Bool Shuffle (array& $array) Shuffle the array for random sorting

21.array_sum () returns the and of all the values in the array, and returns the results of all the values in the array as integers or floating-point numbers;

22.Array range (mixed$start,mixed$limit[,number$step=1]) generates a specified range

array, If the value of step is given , he will be the non-progressive value between the Units. Step should

is Positive. If not specified,step defaults to 1.

23.boolarray_key_exists (mixed$key,array$search) Determines whether a key value exists;

Two Database extension Functions

1.mysql_error (): Gets the error message, if any, that is executed by the last Statement.

2.mysql_num_rows ($result);: Gets the result set $result

"number of rows";

3.mysql_num_fields ($result); Gets the "number of columns" of the result set $result;

4.mysql_field_name ($result, $n); Gets the field name of the nth field in the result set (n starts at 0).

5.file_exists ($file) Determine if a file exists

6.$_server[];

Three String handling functions

1.Strstr () The function is case-sensitive to find the first occurrence of a target string in another string.

If you want to be case-insensitive, use strstr ().

2.strpos () Find where the string first appears

Int Strrpos (string$haystack,string$needle[,int$offset=0]-

calculates the location of the last occurrence of the specified string in the target string,offset may

Finds substrings of any length in the String. A negative value causes the lookup in the string

Ends at the counting position at the beginning of the End.

3.strlen () Gets the string length

4.STRCHR () finds the last occurrence of a string, from that position to the last

5.number_format () formats numbers with a specific character through the thousands group, and preserves

Specify the length!

7.MD5 () The array can be 16-bit (false) or 32-bit (true) as needed

Encryption!

8.md5_file () file Encryption method!

9.Strcmp (string$str1,string $str 2) strcasecmp (string $str 1

, String$str2) compares strings, followed by an ignorable case (greater than return 1,

less than return -1, equals return 0)

10.substr ("string", Start,length) is taken from the specified position in the specified string

Out a specified length string

11.unix_timestamp () Current time acquisition function in MySQL

12.session_name () Get Sessio name

13.Mixed Str_replace (mixed$search,mixed$replace,mixed$subject[,int

& $count] substring substitution, The function returns a string or an array.

14.String RTrim (string $str [, string $characte _mask]

removes whitespace characters (or other characters) at the end of a string, by specifying character_mask,

You can specify a list of characters that you want to Delete. Simply list all the characters you want to Delete. Use : Format

, you can specify a Range.

"" (ASCII (0*20)), Plain white space character.

16.? "\ t" (ASCII 9 (0x09)) , tab.

17.? "\ n" (ASCII (0x0A)) , Line Break.

18.? "\ r" (ASCII (0x0D)) , the carriage return character.

19.? "\" (ASCII 0 (0x00)) , NUL NULL byte character.

20.? "\x0b" (ASCII One (0x0B)) , Vertical tab.

21.Int substr_count (string $haystack, string$needle[,int$offset=0[,int$length

]]) calculates the number of occurrences of a string

Four Typical technical operation functions

1.mysql_real_escape_string ($string) escapes special characters in the string used in the SQL statement,

And considering the current character set of the connection

2.mt_rand () returns min ( or 0) to max ( or to Mt_getrandmax ()), containing the number of random numbers between the Values.

3.ImageCreate ( wide, high ); Create a color-based canvas

4.imageCreateTruecolor ( wide, high ); Create a true Color canvas

5.imagecreateFromJPEG ( image address ) Create a canvas based on image (jpeg format)

6.Imagecolorallocate(canvas, color R, color G, color B) Assign colors to the canvas

7.imagFILL ( canvas, fill position X, fill position Y, color identification )

8.Uniqid (string, Bool) generates a unique ID based on time

9.str_repeat () repeats a string

10.move_uploaded_file ( Pro mu file, target file ) will be temporarily persisted into storage

11.is_uploaded_file to see if that file was uploaded through Httppost.

12.Date () formats local Time.

13.is_dir () Determines whether the directory Exists.

14.MKdir () Create a Directory.

15.array_pop () pops the last cell of the array (out of the Stack)

16.Getimagesize () Get more information about a picture

17.Iconv (' Raw code ', ' target table code ', ' What to convert ') quasi-swap character encoding

18.GETCWD () Get current working directory

19.directory_serparator separators under the current system

20.UCFIRST() First letter capitalization

21.sql_autoload_register Register __autoload () function

22.Trim ()

23.Addslashes () Use single quotation marks to reference strings

24.Intval () cast to type int

25.php_eol is converted to different operators under different operating systems

26.Addslashes: Use a backslash to reference a string (normal function, considered from the Program's level)

The arrangement of elements function of PHP array

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.