The PHP function of tamping basic-----familiar with five functions every day--string function three

Source: Internet
Author: User

Function One:

count_chars- returns information about the characters used in the string

Each string byte value in the statistic (0: 255) The number of occurrences, using multiple modes to return results. The optional parameter mode default value is 0. Depending on the mode difference,count_chars () returns the following different results:

    • 0-An array of values as the number of occurrences of each byte value as the key name.
    • 1-Same as 0, but only byte values with occurrences greater than 0 are listed.
    • 2-Same as 0, but only byte values with occurrences equal to zero are listed.
    • 3-Returns a string consisting of all used byte values.
    • 4-Returns a string consisting of all unused byte values.

The information for the characters in the statistics string.

Function Two:

explode- uses a string to split another string, returning an array

Descriptionarray explode ( string $separator , string $string [, int $limit ])

This function returns an array of strings, each of which is string a substring separated by a string separator as a boundary point. If a limit parameter is set, the returned array contains the limit largest number of elements, and the last element string will contain the remainder.

If separator the string is empty (""),explode () returns FALSE . If separator the contained string value is not found in, then explode () returns an array containing string a single element.

If limit The argument is a negative number, all elements except limit the last-element are returned. This feature is new in PHP 5.1.0.

For historical reasons, although implode () can receive two parameter sequences, explode () does not work. You must make separator sure that string the arguments precede the arguments.

Function Three:

implode (in terms of what to splice, the array to splice); return a string, implode- Join array elements with a string.

Function Four:

fprintf- writes the formatted string to the stream

int fprintf ( resource $handle , string $format [, mixed $args [, mixed $... ]])

Writes a format formatted string to a stream opened by handle a handle.

Return value: Returns the length of the write String.

   <?php
if (!($fp = fopen(‘currency.txt‘, ‘w‘))) {
    return;
}

$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$len = fprintf($fp, ‘%01.2f‘, $money);
// will write "123.10" to currency.txt

echo "wrote $len bytes to currency.txt";
// use the return value of fprintf to determine how many bytes we wrote
?>
Function Five:

get_html_translation_table- returns the conversion table after using Htmlspecialchars () and htmlentities ().

Descriptionarray get_html_translation_table ([ int $table = html_specialchars [, int $quote_style = Ent_co Mpat]])

get_html_translation_table ( ) returns the converted table after Htmlspecialchars () and htmlentities () processing.

Note:

Special characters can be used in a variety of ways. For example: " can be converted into &quot;, & #34; or & #x22.   get_html_translation_table () returns one of the most commonly used.

The PHP function of tamping basic-----familiar with five functions every day--string function three

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.