PHP row selection. Reading a file in PHP. We select the optimal option. Automatically remove html tags from the row

Golovna / Google Play

Insert HTML code for the row opening before the skin row shift

  • number_format - Format number with separate groups
  • ord - Rotate the ASCII code of a character
  • parse_str - Parse a row for changes
  • print - Display a row
  • printf
  • quoted_printable_decode - Rozkoduє row, coding method quoted printable
  • quotemeta - Screenshot of special symbols
  • rtrim - Seeing clearings from the end of the row
  • sha1 - Rotate SHA1 hash rows
  • sha1_file - Check the SHA1 hash of a file
  • similar_text - Calculate the degree of similarity of two rows
  • soundex - Turn the soundex key to row
  • sprintf
  • sscanf - Matches a row according to the given format
  • strcasecmp - Row reversal without register adjustment, safer for data in dual form
  • strcmp - Row order, safety for data in double form
  • strcoll - Row alignment with thread locale fixes
  • strcspn - Turn the dovzhina of the plot on the cob of the row, so that the mass does not
  • stripcslashes - Stripe character screen broken by addcslashes() function
  • stripos - Rotate the position of the first entry of the order without raising the register
  • stripslashes - Displays the character screen, breaks with the addslashes() function
  • strip_tags - Renders HTML and PHP strip tags
  • stristr - An analogue of the strstr function, but keep it in register
  • strlen - Turn the back of the row
  • strnatcasecmp - Matching rows without adjusting the register with the matching algorithm
  • strnatcmp - Row order matching to the "natural ordering" algorithm
  • strncasecmp
  • strncmp - Reversal of first n characters in rows without case-adjustment, safer for data in double form
  • strpos - Know the first entry of the order in a row
  • strrchr
  • strrev - Reverse row
  • strripos - Rotate the position of the remaining entry of the order without raising the register
  • strrpos - Know the remaining input of a character in a row
  • strspn - Turn the dovzhina of the plot on the cob of the row
  • strstr - know the first order entry
  • strtok - Breaking a row
  • strtolower - Converts a row to lowercase
  • strtoupper - Converts a row to uppercase
  • strtr - Rewrite given characters
  • str_ireplace - Registry-independent variant of the str_replace() function.
  • str_pad - Pad row with the next row up to the specified length
  • str_repeat - Rotate the row to be repeated
  • str_replace - Replace a search row with a replace row
  • str_rot13 - Wicon over ROT13 rotation row
  • str_shuffle - Swap characters in a row
  • str_split - Split a row into an array
  • str_word_count - Return information about the words that enter up to the row
  • substr - Function to rotate part of a row
  • substr_count - Pіdrakhovuє kіlkіst vіdzhenі podryadka v ryadka
  • substr_replace - Replace part of a row
  • trim - You have seen the cob of the cob and the end of the row
  • ucfirst - Converts the first character of the string to uppercase
  • ucwords - Convert to uppercase the first character of a skin word in a row
  • vprintf - Print a format string
  • vsprintf - Rotate a formatted row
  • wordwrap - Wrapping a row for the number of characters per number of characters for expanding a row
  • Peculiarities of operators in the order of hundred rows.

    $one = 1; // Number one. $zero = 0; // Invite the number zero. if ($one == "") echo 1; // Obviously more than one - don't display 1. if ($ zero == "") echo 2; //* Respect! Vsuperech ochіkuvannyam drukє 2! if ("" == $zero) echo 3; //* Don't help either - friend!.. if ("$zero" == "") echo 4; // That's right. if (strval($zero) == "") echo 5; // It's also correct not to display 5. if ($zero === "") echo 6; // The shortest way but not in PHP 3.

    chop()

    The chop() function rotates a row after a new trailing overflow and a new row character. The syntax of the chop() function is:

    string chop(string row)

    In the attacking application, the chop() function sees the entry characters of the new row:

    $header = "Table of Contents\n\n"; $header = chop($header); // $header = "Table of Contents"

    str_pad()

    The str_pad() function changes the row to the last line with the given characters and rotates the formatted row. Syntax of the str_pad() function:

    string str_pad (string row, int padding_older [, padding string [, int padding_type]])

    Although the optional language parameter is not specified, the row is supplemented with spaces. In another way, the row is supplemented with given symbols. Behind the lock, the row is supplemented with a right hand; Timing is not less, you can pass the constant STR_PAD_RIGHT, STR_PAD_LEFT or STR_PAD_BOTH to the parameter type_additional, which will result in an additional row in the given one directly. The butt demonstrates an additional row of the str_pad() function with parameters behind the promotion:

    $food = "salad"; print str_pad ($food, 5): // Display row "salad" Paddle pad has some non-language parameters of function str_pad(): $header = "Table of Contents"; print str_pad ($header, 5, "=+=+=" , STR_PAD_BOTH);// Browser will display row =+=+= Tab of Contents=+=+="

    trim()

    The trim() function removes any gaps from both edges of a row and rotates any gaps in a row. The syntax of the trim() function is:

    string trim (string edge)

    The special characters \n, \r, \t, \v і \0 are included before the next overflows.

    ltrim()

    The lrim() function detects all gaps and special characters from the left edge of the row and reverses the row. Syntax of the ltrim() function:

    string ltrim (string row)

    The function removes the special characters themselves, just like the trim() function.

    strlen()

    Appointment of the dozhini row

    More than a row of characters can be assigned to the help function strlen(). strlen() functions:

    int strlen (string row)

    The stepping butt demonstrates the designation of the previous row with the strlen () function:

    $string = "hello"; $length = strlen($string); // $length = 5

    Pairing of two rows

    Pair two rows to lie down to the most important row operations, be it a move. If you want the task, you can change the kіlkom different ways, RNR has several row-spacing functions:

    strcmp()

    The strcmp() function sorts two rows of character case adjustments. Syntax of the strcmp() function: int strcmp (string row1, string row2)

    After the end of the sequence, strcmp() rotates one of three possible values:

    • 0, so row1 and row2 run;
    • < 0, если строка1 меньше, чем строка2;
    • > 0, so row2 is smaller, row1 is lower.

    $sthng1 = "butter"; $string2 = "butter"; if ((strcmp($string1. $string2)) == 0) : print "Strings are equivalent!"; endif; // The if command turns TRUE

    strcasecmp()

    The strcasecmp() function works the same way as strcmp(), with one fault - the register of symbols is not protected when they are reversed. The syntax of the strcasecmp() function is:

    int strcasecmp (string string1, string string2)

    The advancing fragment has two identical rows:

    $string1 = "butter"; $string2 = "Butter"; if ((strcmp($string1, $string2)) == 0) : print "Strings are equivalent!"; endif; // The if command turns TRUE

    strspn()

    The strspn() function rotates the length of the first segment of row1, which to replace characters, which to row2. Syntax of the strspn() function:

    int strspn (string row1, string row2)

    The following snippet shows how the strspn() function is used to reverse the password:

    $password = "12345"; if (strspn($password, "1234567890") != strlen($password)) : print "Password cannot consist solely of numbers!"; endif:

    strcspn()

    The strcspn() function rotates the length of the first segment of row1 to replace characters that are the same to row2. Syntax of the strcspn() function:

    int strcspn (string row1, string row2)

    In the next fragment, the strcspn() function is hacked to check the password:

    $password = "12345"; if (strcspn($password, "1234567890") == 0) : print "Password cannot consist solely of numbers!"; endif;

    Obrobka ryadkovyh data without zastosuvanya regular virus

    When processing great information, the functions of regular viruses are greatly improved by the programs. These functions should be slowed down for less than an hour of processing of foldable rows, for which regular use is necessary. As the analysis of the text follows apparently simple rules, you can speed up the standard functions of PHP, so you can quickly speed up the processing. All functions are described below.

    strtok()

    The strtok() function splits a string into tokens after splitters given by another parameter. Syntax of the strtok() function:

    string strtok (string row, string splitters)

    The strtok() function has one quirk: in order to split the row again, the function needs to consecutively cycle through the row. With a black ring, the function sees a lexeme in a row. In this case, the row parameter is set only once - the function will show the current position in the row of dots, the docks of the row will not be repeated on the token, or there will be no tasks new parameter row. The stepping butt demonstrates the splitting of the row for the dekilkom by the retailers:

    $info = "WJ Gi1more: [email protected]| Columbus, Ohio"; // Tokenized - two dots (:), vertical rice (|) and coma (.) $tokens = ":|,"; $tokenized = strtok($info, $tokens); // Enter array elements $tokenized while ($tokenized) : echo "Element = $tokenized
    "; // Caution: on upcoming wicks strtok // first argument not passed $tokenized = strtok($tokens); endwhile; Result: Element = WJGilmore Element = [email protected] Element = Columbus Element = Ohio

    parse_str()

    The parse_str() function sees in a row the pars and given values ​​of the changes in the streaming scope. Syntax of parse_str() function:

    void parse_str(string row)

    The parse_str() function is especially handy when parsing a URL to parse given HTML forms or other extended information. For which application the information is analyzed, transmitted via URL. Row є standard way transferring data between the parties or compiling from hyperpositive, or introducing from HTML form:

    $url = "fname=wj&lname=gilmore&zip=43210"; parse_str($url); // After the parse_str() has changed, the following changes are available: // $fname = "wj": // $lname = "gilmore"; // $zip = "43210"

    Oskіlki tsya function was created for working with URLs, it ignores the ampersand character (&).

    explode()

    The explode() function splits a row into elements and rotates the elements in a look-alike array. Explode() function syntax:

    array explode (string splitter, string row [, int threshold])

    Razbittya depends on the skin instance of the retailer, and the number of taken fragments can be separated by a non-binding threshold parameter.

    The sub-row of the explode() function is demonstrated in the step-by-step application:

    $info="wilson|baseball|indians"; $user = explode("|", $info); // $user="wilson"; // $user = "baseball"; // $user = "Indians";

    The explode() function is practically identical to the regular POSIX split() function described above. The main thing is that passing regular variables in parameters is allowed only for the split() wiki.

    implode()

    Just like the explode() function splits a row into elements of an array, the twin - the implode() function - combines an array into a row. Syntax of implode() function:

    string implode (string expander, array fragments)

    The formation of a row from an array is demonstrated in an offensive stock:

    $ohio_cities = array("Columbus", "Youngstown", "Cleveland", "Cincinnati"); $city_string = implode("l", $ohio_cities); // $city_string = "Columbus | Youngstown | Cleveland | Cincinnati";

    implode() has an alias, the join() function.

    strpos()

    The strpos() function knows the first instance of the given sequence in a row. Syntax of the strpos() function:

    int strpos (string string, string string [, int string])

    The neobov'yazkovy parameter offset determines the position, for which the search is to be blamed. As a rule of thumb, strpos() returns FALSE (0).

    For the attacking butt, the position of the first entry date is assigned to the log file:

    $log = " 206.169.23.11:/www/:2000-08-10 206.169.23.11:/www/logs/:2000-02-04 206.169.23.11:/www/img/:1999-01-31" // What is the position of the journal in 1999? $pos = strpos($log, "1999"); // $pos = 95. shards the first instance of "1999" // be in position 95 of the row, which should be moved to the changed $log

    strrpos()

    The strrpos() function is to know the row of the remaining example of the given character. Syntax of the strrpos() function:

    int strpos (string row, character char)

    For the possibilities, this function yields to its twin - the strpos () function, the shards allow only a small symbol, but not the whole row. Likewise, in another parameter of strrpos(), a row is passed, for an hour, I will ask for more than the first character.

    str_replace()

    The str_replace() function searches the row for all entries of the given subroutine and replaces them with a new subroutine. Syntax of the str_replace() function:

    string str_replace (string replacement, string replacement, string row)

    The function substr_replace(), described below in this section, allows you to carry out a replacement only in the song part of the row. The following shows how the str_replace() function is vindicated for a global replace in a row.

    Every once in a while, the order of the day does not grow in a row, the exit row does not change:

    $favorite_food = "My favorite foods є ice cream and chicken wings"; $favorite_food = str_replace("chicken_wings", "pizza", $favohte_food); // $favorite_food = "My favorite foods є ice cream and pizza"

    strstr()

    The strstr() function rotates a part of a row that starts from the first entry of the given row. Syntax of the strstr() function:

    string strstr (string row, string sequence)

    In this application, the strstr() function is used to see the domain name from the URL:

    $url = "http://www.apress.com"; $domain - strstr($url, "."); // $domain = ".apress.com"

    substr()

    The substr() function rotates the part of the row that starts from the given cob position and may be given the given root. The syntax of the substr() function is:

    string substr (string row, int cob [, int back])

    If the non-binding parameter of the length is not specified, it is important that the row starts from the given cob position and continues until the end of the row. When vikoristannye tsієї funktії nebhіdno vrakhovuvat chotiri furnish:

    • If the cob parameter is positive, the rotation of the row starts from the position of the row from the given number;
    • If the cob parameter is negative, the row is rotated from the position (row row - cob);
    • If the back parameter is positive, the rotation of the sequence will include all symbols from the position of the ear to the position of the ear + back. As if the remaining value is moving the length of the row, the symbols are rotated to the end of the row;
    • For example, the parameter Dozhina vіd'єmniy, substring, scho to turn, ends on the task of the line at the end of the row.

    Remember that the cob parameter is set to the first character in the row; in such a rank, the row that turns, really starts with a symbol with a number (cob + 1).

    The stepping butt demonstrates the view of a part of the row with the substr() function:

    $car = "1944 Ford"; smodel = substr($car, 6); // Model = "Ford"

    Butt іz positive parameter dozhina:

    $car = "1944 Ford"; $model = substr($car, 0, 4); // $model = "1944" Butt іz negative parameter dozhina: $ car = "1944 Ford"; $model = substr($car, 2, -5); // $model = "44"

    substr_count()

    The substr_count() function turns the number of entries in the job row into the job row. Syntax of substr_count() function: int substr_count (string string, string substring) In the offensive application, the substr_count() function sets the number of substring inputs ain: $tng_twist = "The rain falls mainly on the plains of Spain"; $count = substr_count($tng_twist, "ain"); // $count = 4

    substr_replace()

    The substr_replace() function replaces a part of a row that starts from a given position. When a non-language parameter is set, the default value is replaced by a fragment of the specified value; in a different way, a change is carried out for all the rows that are replaced. Syntax of substr_replace() function:

    string substr_replace (string row, string replace, int ear [, int old])

    The parameters of the cob and dozhina are set according to the following rules:

    • if the cob parameter is positive, the change starts from the given position;
    • If the cob parameter is negative, the change starts from the position (row row-cob);
    • if the value parameter is positive, the fragment of the specified value is replaced;
    • If the row length parameter is negative, the replacement is completed in the position (row row length - row length).

    A simple replacement of the text with the substr_replace() function is demonstrated in the step-by-step application:

    $favs = " s favorite links"; $name = "Alessia"; , 0, 0);print $favs:

    Result:

    Alessia's favorite links

    Convert rows and files in HTML format and navpackages

    Convert a row or whole file to a format that is suitable for review in a web browser (or navpacki), simpler, lower, you can look at the first glance. RNR has special functions when it comes to it.

    Converting text to HTML

    Shvidke conversion of plain text to the format of a web browser - even wider than the task. At її vyshenni you will be supplemented by the functions described in this section.

    nl2br()

    The nl2br() function replaces all newline characters (\n) with equivalent HTML constructs.

    Syntax of nl2br() function:

    string nl2br (string row)

    The characters of the new row can be visible (thus explicitly included in the row), or invisible (for example, entered in the editor). In the attacking butt, the text row is converted to HTML format for additional replacement of characters \n with line breaks:

    // Text row as shown by the editor. $text_recipe = "Party Sauce recipe: 1 cans rajčata 3 tablespoons fresh lemon juice Stir together, server cold."; // Reverse the symbols of the new row to
    $htinl_recipe = nl2br($text_recipe) When $html_recipe is rendered offensively, the browser will pass the offensive text in the HTML format: Party Sauce recipe:
    1 can stewed tomatoes
    3 tablespoons fresh lemon juice
    Stir together, server cold.

    htmlentities()

    The htmlentities() function converts characters to equivalent HTML constructs. The syntax for the htmlentities function is:

    string htmlentities (string row)

    At the stepping butt, a necessary change of the symbols of the line for displaying at the browser is carried out:

    $user_input = "Cookbook, like a Cafe Francaise"

    The htmlentities() function only works for ISO-8559-1 (ISO-Latin-1) encoding characters. In addition, they won’t turn the clearing into, as if it were a boulder to clear up.

    htmlspecialchars()

    The htmlspecialchars() function replaces some characters that may have special meaning in an HTML context with equivalent HTML constructs. Syntax of htmlspecialchars() function:

    string htmlspecialchars (string row)

    The html special chars() function transforms the following characters in this hour: & transforms to &; "" changes to " ; changes to >.

    Zocrema, this function allows you to override the introduction of HTML coders in interactive web add-ons (for example, in electronic forums). Pardons allowed in HTML formatting can cause the side to be formatted incorrectly. Vtіm, tse zavdannya іsnuє y аnd аnd аnd аnd аn efficient solution - tо remove the tags from the row using the strip_tags() function.

    The stepping butt demonstrates the removal of potentially unsafe characters using the htmlspeclalchars() function:

    $user_input = "I just can"t get of PHP & those fabulous cooking recipes!"; $conv_input = htmlspecialchars($user_input); // $conv_input = "I just can"t<> of PHP & those fabulous cooking recipes!"

    If the htmlspecialchars() function is cycled by nl2br(), then I'll leave a trace of the click after htmlspecialchars(). In a different way of construction
    , generated every hour of the nl2br() call, are converted to visible characters.

    get_html_translation_table()

    The get_html_translation_table() function takes care of manually converting the text to the HTML equivalent Syntax of the get_htrril_translation_table() function:

    string get_html_translation_table (int table)

    The get_html_translation_table() function rotates one of two translation tables (specified by the table parameter), which are converted into standard functions htmlspecialchars() and htmlentities(). The value that turns around can win in the future with another standard function, strtr(), to convert text to HTML code.

    The table parameter takes one of two values:

    • HTML_ENTITIES;
    • HTML_SPECIALCHARS.

    In an attacking application, the get_html_translation_table() function is broken when converting text to HTML code:

    $string = "La pasta e il piatto piu amato in Italia"; $translate = get_html_translation_table(HTML_ENTITIES); print strtr($string, $translate); // Special characters converted to HTML constructs // and rendered correctly in the browser.

    Speaking of which, the array_flip() function allows you to flip the text into HTML in a reversed way and retrieve the original text. Let's say that instead of seeing the result of strtr() in the front butt, we put a different $translated string.

    In which case, the output text is modified by the array_flip() function:

    $translate = array_flip($translate); $translated_string - "La pasta é il piatto piu amato in Italia"; $original_string = strtr($translated_string, $translate); // $original_string = "La pasta e il piatto piu amato in Italia";

    strtr()

    The strtr() function translates a row, so that it replaces all the characters that enter before the row with the same characters of the destination row. Syntax of the strtr() function:

    string strtr (string row, string dzherelo, string priymach)

    As if the rows were dzherelo that priymach may be rіznu dozhina, the long row is truncated to a short row.

    Use an alternative syntax to the wiki's strtr() with two parameters; In this way, another parameter is to replace the associative array, the keys of which one should be given to the substrings that are being replaced, and the value - to the replacement substrings. In the attacking application, HTML tags are replaced by XML-like constructs:

    " => "

    ", "" => "

    "); $string = "

    Today In PHP-Powered News

    "; print strtr($string, $source); // Display row " Today in PHP-Powered News" ?>

    Converting HTML to Plain Text

    Sometimes you need to convert the file in HTML format to plain text. The functions described below will help you complete the task.

    strip_tags()

    The strip_tags() function strips all the HTML and PHP tags in a row, overwriting the text. The syntax of the strip_tags() function is:

    string strip_tags (string strip [, string allow_tags])

    The optional language parameter allow_tags allows you to specify tags that should be skipped in the removal process.

    Below is an example of how to strip all HTML tags using the strip_tags() function:

    $user_input = "I just love PHP and gourment recipes!"; $stripped_input = strip_tags($user_input); // $stripped_input = "I just love PHP and gourmet recipes!";

    At the offensive butt, not all, but only some tags are visible:

    $input = "I love to eat!!"; $strip_input = strip_tags($user_input, " "); // $strip_input = "I love to eat!!";

    Visible tags from the text are also seen by the fgetss() function.

    get_meta_tags()

    If you want the get_meta_tags() function and can't directly refer to the text, it's just a basic function, you can guess about it. Syntax of get_meta_tags() function:

    array get_meta_tags (string filename/URL [, int include_path])

    The get_meta_tags() function is recognized for searching HTML files for META tags.

    META tags to remove information about the side, as they are won by the head rank of poshuk systems. Qi tags are located in the middle of bet tags... . Insertion of META tags is demonstrated in the next snippet (let's call it example.html, the code snippets will be featured in Listing 8.2): Listing 8.2 shows the pasting of this function to the example.html file. Listing 8.2. Retrieving META tags from an HTML file using the get_meta_tags() function

    $meta_tags = get_meta_tags("example.html"): // Change $meta_tags to retrieve an array with this information: // $meta_tags["keywords"] = "PHP, code, recipes, web" // $meta_tags["description" ] = "PHP info" // $meta_tags["author"] = "KDG";

    More details: these META tags can be used not only for files that are on the server, but also for other URLs.

    Rearranging a row to upper and lower case

    PHP has several functions that are used to change the register of a row:

    strtolower()

    The strtolower() function converts all alphabetic characters of the string to lowercase. The syntax of the strtolower() function is:

    string strtolower(string row)

    Non-alphabetic characters and functions are not changed. Reversing the row to lowercase with the strtolower() function is shown in the footer:

    $sentence = "COOKING and PROGRAMMING PHP є my TWO favorite!"; $sentence = strtolower($sentence); // After calling the $sentence function, sweep the row // "cooking and programming php are my two favorite!"

    strtoupper()

    Rows can be changed not only to the lower, but also to the upper register. The changeover is made to the strtoupper() function so that the following syntax can be used:

    string strtoupper (string row)

    Non-alphabetic characters and functions are not changed. Reversing the row to uppercase with the strtoupper() function is shown in the footer:

    $sentence = "cooking and programming PHP are my two favorites!"; $sentence = strtoupper($sentence); // After calling the $sentence function, sweep the row // "COOKING AND PROGRAMMING PHP ARE MY TWO FAVORITE!"

    ucfirst()

    The ucfirst() function converts the first character of the row to uppercase - figure out which is the alphabetic character. Syntax of ucfirst() function:

    string ucfirst (string row)

    Non-alphabetic characters and functions are not changed. The transformation of the first character of a row by the ucfirst() function is shown in the step-by-step application:

    &sentence = "cooking and programming PHP are my two favorites!"; $sentence = ucfirst($sentence); // After calling the $sentence function, sweep the row // "Cooking and programming PHP are my two favorite!"

    ucwords()

    The ucwords() function converts the first letter of the skin word in a row to uppercase. Syntax of ucwords() function:

    string ucwords (string row")

    Non-alphabetic characters and functions are not changed. The "Word" is regarded as a sequence of symbols, embodied in other elements in a series of gaps. At the offensive butt, the transformation of the first symbols of the words was demonstrated by the ucwords () function:

    $sentence = "cooking and programming PHP are my two favorites!"; $sentence = ucwords($sentence); // After the $sentence function tweet sweep the row // "Cooking And Programming PHP Are My Two Favorite!"

    strchr()

    strrchr("row", "o") - Find the remaining entry of the row

    If the order is not found, turn FALSE.

    On the view of strchr(), as a row is added more and more of one character, only the first character is beaten.

    If another parameter is not in a row, it is pointed to an integer and is interpreted as a code for a character.

    // subtract the rest of the $PATH directory $dir = substr(strrchr($PATH, ":"), 1); // remove everything after the rest of the row shift $text = "Line 1\nLine 2\nLine 3"; $last = substr(strrchr($text, 10), 1);

    highlight_string()

    highlight_string - visualization of the row syntax.

    mixed highlight_string(string str[, bool return])

    The highlight_string() function displays the syntax-reversed version of the str string, with the highlight colors assigned to the syntax-enhanced PHP syntax.

    As well as the other return parameter, which can be TRUE, highlight_string() will turn the version of the forged code in a row, instead of each other. If no other parameter can be TRUE, highlight_string() will turn TRUE on success, FALSE on failure.

    Note: 1. The return parameter became available starting with PHP 4.2.0. Until tsgogo vin pratsyuvav, like for umovchannyam, tobto. FALSE.
    2. The Highlight_String() function separates PHP code behind tags. show_source()- synonym highlight_file(). To change the color of the vision behind the lock, match the following PHP directives:

    Highlight.bg #FFFFFF highlight.comment #FF8000 highlight.default #0000BB highlight.html #000000 highlight.keyword #007700 highlight.string #DD0000 in .htaccess: php_flag highlight.bg #FFFFFF in PHP: .bg")==" ") ...

    addslashes()

    - Screen special characters in a row

    Let's turn the term, in which a backslash (\) is added before the skin special character, for example, for a distant alternative row in the request to the data base.

    A single foot ("), a single foot ("), a backslash (\) and a NUL (NULL byte) are screened.

    $str = "Is your name O"reilly?"; // output: Is your name O\"reilly? echo addslashes($str);

    stripslashes

    - Seeing the character screen, breaking the addslashes() function Seeing the backlash screen. ("transform into", etc.). Underwire bekleshi (\\) transform into single (\).

    wordwrap()

    Wrapping a row by the number of characters for the number of characters to expand the row // Wordwrap() variable. function cite($ourText, $maxlen=60, $prefix="> ") ( $st = wordwrap($ourText, $maxlen-strlen($prefix), "\n"); $st = $prefix.str_replace( "\n", "\n$prefix", $st);, return $st; No doubt that this monument has special respect for nature. was again frustrated by failure.", 20);

    > The first Matrix I > designed was quite > naturally > perfect, it was a > work of art - > flawless, sublime. > A triumph > equalled only by > its monumental > failure. The > inevitability > of its doom is > apparent to me now > as a consequence > of > imperfection > inherent in every > human being. To that, > I > redesigned it > foundations on your > history on more > accurately reflect > the varying > grotesqueries of > your nature. > However, I was > again > frustrated by > failure.


    Read more:

    Sites can be divided into static and dynamic. After mastering HTML and CSS, it will allow you to create a business card on the Internet, so many people will try to create a dynamic site in PHP. For this reason, the editor is guilty of lying, that now he is starting to develop web programming: the principles of work with the site are taken care of. One of the first problems that PHP has to deal with is the row-by-row robot that reads that file.

    Varto means that in PHP there is a large number of methods, to start with the simplest manipulations, such as the introduction of a row, poshuk, otrimannya or a replacement of a row, a change of register and rotation of a row. A lot of functions are badly processed with Cyrillic characters. To this, all applications are written in English for accuracy. For Cyrillic, the same functions are used, but with the mb_ prefix (for example, mb_strpos()). The first step is to select analogues, in php.ini it is necessary to comment out the row; extension = php_mbstring.dll, just clean up the mess.

    Creation and vision of a row

    Let's take a look at the display of a row on the screen behind the help of a moving construction echo. The programmer can enter a row in a row:

    echo "Tse New Row"

    otherwise, create a change, and then bring it to the screen:

    $str = "Tse New Row";

    If it is necessary to put a spear of rows in one, then we go into the їхної concatenation:

    echo "Ce". "Nova". "Row";

    $str1 = "Ce";

    $str2 = "Nova";

    $str3 = "Row";

    echo $str1. $str2. $str3;

    In the rest of the day, it will be shown on the screen PriceNewRow. Probіl can be added to the prompt at echo:

    echo $str1. "". $str2. "". $str3;

    In this view, the screen will show: "Tse Nova Ryadok." Concatenation is possible not only for the first hour of seeing, but for the first hour of the creation of a row:

    $str1 = "Ce";

    $str2 = "Nova";

    $str3 = "Row";

    $string = $str1. "". $str2. "". $str3;

    echo $string;

    Echo display like this and Cyrillic. As if one of the changes made a number, then when concatenating the whole number will be turned into a second row:

    $sum = $i + $i; //now $sum to avenge the number 4

    echo $i. "+". $i. "=". $sum;

    The screen will display: "2+2=4".

    Service symbols

    Let's say the row is assigned for help ($string = "Axis so"). Then you can calmly beat the key sequences:

    • \n zdіysnyuє row shift;
    • turn the carriage;
    • screen of underfoot:
      • echo "Row with "swinging" paws"; // Row with "swinging" paws
    • \$ screen dollar;
    • screen scythe between.

    There are many more sequences, all of which can be found in the official PHP documentation.

    How to know the position of the first entry

    Suppose we have a simple row:

    So we have two rows with names:

    $name = "Yemelian";

    $anotherName = "Katherine";

    We need to know how to avenge the first row and two names. For which the strpos($str, $search) function is used. She turns the position of the $search row, so that the row moves away from the $str. In another way, the function turns the value to false. For example, strpos($string, $anotherName) is false, and strpos($string, $name) is an integer. The code will be like this (we will write an option if the position is displayed on the screen):

    $string = "My name is Yemelyan and I am 27 year old";

    $name = "Yemelian";

    $anotherName = "Katherine";

    echo strpos($string, $anotherName); //vivede false

    echo strpos($string, $name); //View the position of the first order entry

    To pay attention, that the numbering of the row starts from zero, so in our case the remaining row will show the number 11 (we also tried it).

    Search for the position of the remaining entrance of the construction work and water stones

    Just as the strpos() function rotates the position of the first entry, the return function strrpos() looks for the remaining entry in the order.

    Here are deaks of water stones, tied with an ear of numbering. Tse varto vrakhovuvati: at PHP robot with rows, buti can be studded with interchanges. So, it's better to win the operation of matching the lists: strpos($str, $search)!=false. Have any version PHP apply with a similar equivalence, they can be misinterpreted, even the numbering of the rows starts from zero, and in a logical interpretation 0 is false. It extends to the strrpos() function.

    How to know the number of entries

    Often it is necessary to know not the position of the first or the last entry of the order in a row, but its total number. For which win the function substr_count() is used, so that the least two changes are processed: substr_count($str, $search). Rotate the whole number. If you need to change the area by the search in order, then two more changes are transferred to the function: the cob and the end of the row are appropriate. So the function is called like this: substr_count($str, $search, $start, $end). The function to shuffle the $search substring between $start and $end of the output row $str. If the row is not found, the function will turn zero.

    How to change row case in PHP: apply

    Changing the register is often victorious for the alignment of rows and it is permissible that the coristuvach is guilty of entering the name of the supreme god. If the input text does not match the actual text (for example, if you write "one" or "ONE"), then the program will turn false instead of true. In order to get rid of this, the function of changing the register will be installed. Tse often vykoristovuetsya, as a site in PHP maє tags: replace hundreds of options for the word "special" ("Special", "special", "Special" then) and only one tag in lower case.

    The strtolower() function changes the case to lowercase. Let's say $catName = "Fluffy" row. The strtolower($catName) function will rotate the "fluffy" row. You can change the case to uppercase with the help of strtoupper().

    How to know the length of a row in PHP: a robot with functions

    It is often necessary to know the length of the row. For example, a PHP robot with rows of this kind might need a create loop. For a joke of a row, the strlen() function is used to rotate the number - the number of characters. You can't forget that the last character of the math number is strlen($str)-1, the shards of numbering start from zero.

    Removing that replacement of a row in PHP: a robot with rows

    The substring is set by the substr() function, so you can take two or three arguments: substr($str, $start, $end). Let's say we have $string = "Fluffy cat", and we want to take a row from another to the fourth character. Oscilki numbering starts from zero, it will look like this: $newString = substr($string, 1, 4). If we enter $newString = substr($string, 1), then we take a substring from another character to the rest (so "luffy"). This code is identical to the same row code for the additional strlen(): substr($string, 1, strlen($string)).

    To replace the order, the str_replace() function is used, as it accepts three changes: str_replace($subStr, $newSub, $str). On the view of the rich functions str_replace() correctly works with Cyrillic characters and does not have an analogue with a prefix. Butt:

    $str = "Hot weather this year!";

    $newStr = str_replace("sweet", "wonderful", $str); //Today's wonderful weather!

    Converting a row to a number

    The skin, who learns web programming, sooner or later has to translate a row of numbers. For which there are two similar functions: intval() and floatval(), both of which accept one change of $string. One type of one stink only depends on the type of data that is rotated: intval() rotates a whole number, and floatval() - a number with a floating point.

    For vikoristannya like intval (), so floatval () is necessary, so that the row starting from digits, they will be converted into a number. If there are any number of letters, the stench is simply ignored. As a row starts with a letter, the rest of the function turns zero. Ideally, a row can take revenge on one's own numbers.

    Putting numbers in a row

    It is often necessary to translate numbers into a row. Let's say that it is necessary to take half of the number and add її y to the square (for example, reverse, equalize: 88 x 88 + 33 x 33 \u003d 8833). In this way, the strval() function wins, as it rotates a row from a number. After that, with a new row, you can change all the other things: change, shukati the entry of the order and other functions. If necessary, the row can be retranslated to the same way as described above.

    In the article, only a small part of all the functions connected with the rows was considered. Some of the non-descriptive functions are based on symbols, but most of them were not included in the material through specificity. To become familiar with these functions, it is necessary to go to the official PHP documentation, which displays the current information.

    Date of publication: 03.01.2018

    I love you, friends! 🙂

    I think that, although not all of them, then most of you are definitely stuck in practice with the need to read information from txt files on equal server scripts. I have received such vipadkіv a lot of kіlka, about the rest of those I will tell you today.

    There is nothing collapsible in any way, but sometimes the eyes grow into a large number of options, which rely on the server-side mov. If you talk specifically about PHP, for which I program at once, then for additional functions you can read multiple files and rows, and as a whole in a row, and in an array, moreover, for the rest of the options, there are more ways to…

    It's a pity that these methods work with different security for files of different structure, and there is no single word about the security of their work in the official documentation; It is possible to judge only from practice, sorting out all possible options.

    Today I will show you the work other functions PHP for reading files, so if you need to create a PHP parser for a file to process real tasks, you know what to choose. And I’ll also show you that the “fighting minds” themselves have the right choice.

    Let's go! 🙂

    Create a PHP parser for a file - use chat

    Before that, for goodness sake, a few words about the task, for which I created a parser file in PHP, and then we chose the optimal options for implementing them.

    As if I had a problem on my robot, I thought it was in the fact that in the database the telephones were stored in the wrong format. I, of course, fixed the bug itself without any problems.

    But what about the work with incorrect information, which at that time was already saved in the database? Obviously, it was necessary to replace it with the correct one.

    For whom I was given a text file with the identifiers of the correspondents and their phones, which would need to be transferred to the database.

    Guilty to say, vin viishov is even more important: 352 Kbytes and 8223 rows of text koristuvach ID:phone_number.

    In a word, the mustache of the zavdannya poked at the urgent reading PHP file by means, seeing the order of the identifier and the phone with further updates of the value of the phone from the koristuvach in the database, found behind the ID.

    My project will be implemented in PHP to the Yii framework, so in the distant butts of the code you will see the elements of the yogo API for robots from the database, zokrema, don’t fawn about it 🙂

    After analyzing the constructions that are in the language, as well as seeing other retailers, according to the chosen ones on the Internet, I could see 4 ways in the distance, which I have given you and I will demonstrate.

    Well, then I'll tell you, according to some criteria, and just like myself, I choose the best option among them. I, obviously, will share the results 🙂

    So the article is given - the exercise of tolerance 🙂 The essence of this is the basis in the report of the offensive material right up to the results, as a check on you in the cinema. Along the way, before the speech, you can work on the fantasy, allowing yourself to choose the ideal option.

    Reading a file in PHP in a row for the help of fgets ()

    As a result, the PHP parser file that implements given algorithm, I have an offensive look:

    find("unique_id IN (:id1, :id2)", array(":id1" => strtolower($params), ":id2" => strtoupper($params))); if ($client) ( $client->phone = str_replace(array("\r", "\n"), "", $params); $client->save(); ) ) ) ) if (!feof ($fh)) ( echo "Error: unexpected fgets() fail\n"; ) fclose($fh); ) else echo "Check the filename, file doesn't exist!"; )

    I will decipher my scribbling, so that someone can blame the colloquialisms of the rozumіnі.

    On the very cob, serpentine $filename Hope the value of the file name, which will be parsed, from the top path to the new one. Next, follow PHP re-verification of the file's base and read the wine for additional functions file_exists()і is_readable() obviously.

    Everything is OK, open the file for the help function fopen(), It is invoked from the PHP pardon control operator in order to enable the pardon control that is generated by this function. Vikoristovuvati yogo virishiv, to generate your own reminder about the pardon of the standard.

    As soon as the file was opened, then we go through all the rows in the cycle, until the file ends, and, as the row is not empty, we distribute the function after the two-row symbol explode().

    Then we check that the id of the phone is not empty, we check the id of the phone in the database according to the ID number i, as it is so, then we update the phone number, removing the 3 value of the number in front of the symbol of the transfer and the beginning of a new row.

    Well, I'm also a shortlisted PHP function strtolower()і strtoupper() for reverification of the number in the database of the correspondent with identifiers, which were registered in different registers, t.to. the stench in my mind was made up of symbols and numbers.

    PHP parsing an array file for help file()

    This method of reading a file in PHP is passing a variable function file() how to open the file and place it in the array. With which elements of the array will be, like, rows to the file, what is considered, what is appropriate in my situation.

    The code of the PHP version of the parser for the attack view file:

    find("unique_id IN (:id, :id2)", array(":id" => strtolower($params), ":id2" => strtoupper($params))); if ($client) ( $client->phone = str_replace(array("\r", "\n"), "", $params); $client->

    Like a bachite, in front of the way the file is read in PHP, which is only read by its cob, the file is opened and immediately read by the function file() deputy liaison officer fopen() + fgets() like before.

    PHP read file to change for help fread()

    Another PHP function to parse the file fread(), for help, you can read various fragments of the file assigned to the date. To read the file in PHP again, like expanding the fragment, I entered the file resize, deleting for the additional function filesize():

    find("unique_id IN (:id1, :id2)", array(":id1" => strtolower($params), ":id2" => strtoupper($params))); if ($client) ( $client->phone = str_replace(array("\r", "\n"), "", $params); $client->save(); ) ) ) ) ) else echo " Check the filename, file doesn't exist!"; )

    The Danish way of reading a PHP file by means of a method, really, is similar to the previous one, to that, regardless of those that, for the help of PHP, the data from the file is read not into an array, but into a row, so it’s all the same converted to an array, because . it is easier to practice with him, lower in a row.

    Converting a row into an array in PHP is the easiest way to do this with the help of the explode() function, which has already been stopped today, as a splitter in the same way as transferring the character to the cob of a row.

    Create a PHP parser for a file based on file_get_contents()

    Well, namkinets, I've devised to implement PHP parsing a file for an additional function file_get_contents(), Yaka i is recognized for reading the file as a whole in a row, tobto. practice, practical, like fread($fp, filesize($filename)).

    Because of this, file_get_contents() independently fetches the file and reads it, just like fread() would need to fetch the file ahead of time via fopen() and remove it for the sleazy thumbnail.

    In general, the PHP parser code for a file based on file_get_contents() will be practical as in the front view:

    find("unique_id IN (:id1, :id2)", array(":id1" => strtolower($params), ":id2" => strtoupper($params))); if ($client) ( $client->phone = str_replace(array("\r", "\n"), "", $params); $client->save(); ) ) ) ) ) else echo " Check the filename, file doesn't exist!"; )

    On whom everything. The time has come to improve the productivity of all the options and check, which PHP parser to the file turned out to be the most optimal for the lesser vikoristannya.

    What is the best way to process files in PHP?

    To choose the most optimal options that you have found, tobto. most seen, I have virіshiv vyznachiti in the skin vapadku. For whom I am quickened by the method described in the article for the benefit.

    According to the PHP functions themselves, reading files in order to achieve even more or less reasonable digits for the hour of their work, I have specially stripped the fragments that are being tested, operations with the data base, so that all types are the same.

    The hour of the PHP script's work is also rounded to the third decimal place after Komi for clarity. up to thousandths of seconds (if you want, you can flock to hundreds, really).

    I remember that when I studied at school and wrote my scientific work in physics (so, such an honor 🙂) on її zahist in front of the university students, I was constantly reprimanded for the lack of number of experiments (I tried 3 achievements for a skin rash). "Lights of Science" called the numbers at 100, or, if only, at 10 experiments for equalizing different situations, so that it would be possible to work like a їx zstavleniya that minimizuvat ymovіrnіst vipadkovoї pervada one over іnhim.

    So, it was possible for me to take a look at them, but I’ve got good recommendations, so I’m going to remind you at once, even though it’s been over 10 years. Tim more, that these recommendations were effectively based on the laws of mathematical statistics and the theory of imovirnosti.

    Well, I don’t pretend to be scientific in my last experiments, I respect the number of 100 experiments as a great task, and the process of conducting them is a very tedious task.

    As a result, I have completed 10 experiments for the skin version of the PHP parser file, which, as it turned out in the result, turned out to be quite enough to see a clear leader without any juggling of facts and zachipok for hundreds and thousandths of a second of a second.

    Calculate the results for the hour of the work of the PHP parsed by me in the file presented in the next table and sorted for PHP functions, based on such stinks.

    experiment fgets() file() fread() file_get_contents()
    1 9,147 9,722 10,539 2,008
    2 8,950 9,006 9,495 1,733
    3 8,821 8,845 9,207 1,642
    4 8,717 8,876 8,931 1,758
    5 9,010 9,091 8,703 1,635
    6 9,110 8,640 9,712 1,633
    7 9,074 9,626 9,13 1,645
    8 8,886 9,204 9,048 1,701
    9 8,667 8,918 9,438 1,713
    10 8,852 9,197 9,537 1,567
    Middle 8,923 9,113 9,374 1,704

    Like bachite, let's get around the value of the hour of the script in the skin of 10 experiments, I've checked the average temperature of the medicine 🙂

    And for itself, the arithmetic average hour of the work of the skin PHP parser file, so that you can show the leader.

    I appeared to him, like a bachite, the remaining option, implementations based on the function file_get_contents(), which vikonuє reading in place of the file in a row, changing it with further transformations in an array and processing in a cycle.

    Reshta options for PHP file parsers work at approximately the same speed.

    Why, having overtaken my own competitors, I, frankly, do not have a proper understanding. I can only admit that the operation is reading the file in a row for help file_get_contents() use less resources, lower molding of the finished array of rows for help file().

    And the priority over fgets() and fread() can be written off for those that are necessary for them to open a file with the help of fopen(), then an hour is required.

    So, really, tse baiduzhe, tk. numbers speak for themselves file_get_contents() PHP parser to a file on a yoga base works 5 times better than others, which made my decision to beat yoga in practice.

    Parsing a file in PHP - visnovki

    As I already spoke on the cob, my last was not є bezdoganny and spiraling exclusively on the withdrawal in the current move, the results are not varto, to that, regardless of the swidcode file_get_contents() in my situation, there are fluctuations, if it is richer and more efficient, then I have directed PHP parsing files.

    On the other hand, forget that PHP itself is synchronous with my programming, so. all server operations are performed sequentially without the possibility of setting up the same parallel run, including on different cores of the server processor.

    Also, for an hour of operation, prescribed for PHP code, you can add a number of factors, among them the main ones - the core interest at the time of PHP program operation.

    I’m especially aware of the last hour of the last one, if the same PHP parser to the file was processed in 9, then in 12, and then again in 9 seconds on the last three iterations through the banal launch of Windows Explorer after another hour, which, naturally, will require server resources.

    Vrahovyuchi tsі osoblinosti, I conducted the experiment almost overnight, one by one, with the same set of running programs, so as not to spoil the resources of the server room.

    That's why, for an hour of carrying out similar experiments with PHP constructs, do the same, because tse, vlasne, the only way to bring experiments to equal minds.

    If you practice with asynchronous server movs (C#, Java) or technologies (Node.js, for example), then, if possible, for experiments, create a workflow that is practical on the seen processor core.

    Well, if you want to know the core of the core is not vague (it’s not surprising if the daily PZ is equal), then you can even know the weakest ambition or, if you want to, with static ambitions, it doesn’t change at the hour.

    I mean, I want to say that code fragments placed in the article can be used not only for parsing text files in PHP, but also for other formats, for example, for parsing CSV files.

    Write your opinions, both positive and negative in the comments under the article - I need your thought for further development 🙂

    See you soon! 🙂

    P.S.: if you need a website, or you need to make an editorial on the essential, but for which there is no time for that, I can request my services.

    Ponad 5 rokiv dosvidu professional website development Robot PHP, opencart, WordPress, Laravel, Yii, MySQL, PostgreSQL, JavaScript, React, Angular and other technologies of web development.

    Dosvіd razrobki projects іv razny ryvnya: landing pages, corporate websites, Internet shops, CRM, portals. Including pіdtrimka and rozrobka HighLoad projects. Submit your applications by email [email protected] .

    The task of parsing and collecting the necessary information from a third-party site is often sent to the web retailer for the most challenging reasons: in this way, you can fill your project with content, dynamically add information like that.

    In such situations, a programmer is asked to ask: how to choose from dozens of libraries? In these articles, we tried to look at the most popular options and choose the best one from them.

    Regular virazi

    Navit irrespective of those that are "regulars" - first, that falls on the thought, win them for the right projects is not varto.

    So, it is better to cope with the simple tasks of the regular language, but it becomes significantly more difficult if you need to parse the large and folding pieces of the HTML code, which, before that, does not follow the song pattern and can forgive syntactical pardons.

    Instead of “finishing” your regular expression in the case of the smallest change in the skin code, it is recommended to use the lower instruments – the simpler, the easier, the better, and the better.

    XPath and DOM

    htmlSQL

    If you don't hack PHP, you can check out a short list of similar tools for other programming languages.

    Rows are an even more important type of data, with which one should be constantly practiced at the top of the Internet distribution order. In this article, 10 more brown tricks are described, how to improve the life of PHP for the lighter.

    Automatically remove html tags from the row

    In case of different forms, which are zapovnyuyuschimi koristuvachy, it is sometimes necessary to remove all the input tags. This task is easily mistaken for the additional strip_tags() function:

    $text = strip_tags($input, "");

    Remove text between $start and $end

    Such a function can be in the arsenal of the retailer: it takes away the original row, the ear and the end, and rotates the text, which moves between $start and $end.

    Function GetBetween($content,$start,$end)( $r = explode($start, $content); if (isset($r))( $r = explode($end, $r); return $r; ) return ""; )

    URL transformation in hyperspace

    If you put the URL on the comment form in your WordPress blog, it will automatically transform into a hyperpost. If you want to implement the same functionality on your site or in a web add-on, you can tweak the following code:

    $url = "Jean-Baptiste Jung (http://www.webdevcat.com)"; $url = preg_replace("#http://(+)#", " ", $url);

    Split text in 140 characters for Twitter

    Maybe you know what Twitter accepts more than 140 characters. If you plan to organize your programs in cooperation with a popular social site of support, then the function, how to create an update of up to 140 characters, singsongly, come to your yard.

    Function split_to_chunks($to,$text)( $total_length = (140 - strlen($to)); $text_arr = explode(" ",$text); $i=0; $message=""; foreach ($text_arr as $word)( if (strlen($message[$i] . $word . " ")<= $total_length){ if ($text_arr == $word){ $message[$i] .= $word; } else { $message[$i] .= $word . " "; } } else { $i++; if ($text_arr == $word){ $message[$i] = $word; } else { $message[$i] = $word . " "; } } } return $message; }

    We can see the charging URL

    A lot of people are being asked to comment on the blog URL, to remove traffic or organize a return link. Such messages zabrudnyayut blog and can become the cause of discord vlasnik in times of great number. So the function will come, it will be more corny!

    $string = preg_replace("/\b(https?|ftp|file):\/\/[ [email protected]#\/%?=~_|$!:,.;]*/i", "", $string);

    Warehouse row convertible

    Is it necessary to generate a warehouse (for post-implementation), what will be the sum of SEO tasks? The next function accepts a row as a parameter and turns the sum from the SEO warehouse tasks. It's just that effective!

    Function slug($str)( $str = strtolower(trim($str)); $str = preg_replace("/[^a-z0-9-]/", "-", $str); $str = preg_replace ("/-+/", "-", $str); return $str; )

    Parsing a CSV file

    CSV (Coma separated values) files are an easy way to save and transfer data, and parsing such files in PHP is extremely easy. Do not believe? The following code demonstrates the processing of a CSV file:

    $fh = fopen("contacts.csv", "r"); while($line = fgetcsv($fh, 1000, ",")) ( echo "Contact: ($line)"; )

    Poshuk row in the next row

    If it’s a row to move in the next row and you need to know yoga, then the task is simply wrong:

    Function contains($str, $content, $ignorecase=true)( if ($ignorecase)( $str = strtolower($str); $content = strtolower($content); ) return strpos($content,$str) ? true: false;

    Verify that the row starts from the song pattern

    How to move programming, for example Java, to change the startWith method / function, as it allows you to reverse, chi start a row from a song template. Unfortunately, PHP doesn't have such a simple built-in function.
    Tim is not smaller, we can create її for ourselves, and it’s even simpler::

    Function String_Begins_With($needle, $haystack) ( return (substr($haystack, 0, strlen($needle))==$needle); )

    We see email charging

    If you wonder how spammers take your email addresses? Everything is simple. Take a web-site (for example, from the forum) and parse the html code to see the emails address. Below the pointing, the code will be removed as a parameter and other all email, which should be in the new. Be kind, don't tag this code for spamming!

    Function extract_emails($str)( // Regular expression so that it extracts all emails: $regexp = "/()+\@(()+\.)+((2,4))+/i"; preg_match_all ($regexp, $str, $m); return isset($m) ? $m : array(); [email protected] Revise other formats: [email protected]; foobar More revision: [email protected] test6example.org [email protected] [email protected] example.org [email protected]!foo!.org foobar"; print_r(extract_emails($test_string));

    © 2022 androidas.ru - All about Android