Questions about the Preg_replace_callback function

Source: Internet
Author: User
PHP manual Preg_replace_callback Function Example 3
Output

What's going on with this $input? Is_array ($input) is not an array why would I output the following HTML format? Furthermore, the HTTP status code of the browser Firebug appears aborted after the IF (Is_array ($input)) statement is removed.

What are the $limit and & $count in an expression? Baidu less than? No case, not very clear after the test


Reply to discussion (solution)

Before asking, there should be no doubt
if (Is_array ($input)) {//If $input is an array
$input = ". $input [1]."; The $input is processed into a string
}

After the question, the manual has been made clear
Limit
The maximum number of replaceable times per pattern used for each subject string. The default is-1 (No limit).

Count
If specified, this variable is populated with the number of times the substitution is performed.
Number of records replaced

Before asking, there should be no doubt
if (Is_array ($input)) {//If $input is an array
$input = ". $input [1]."; The $input is processed into a string
}

After the question, the manual has been made clear
Limit
The maximum number of replaceable times per pattern used for each subject string. The default is-1 (No limit).

Count
If specified, this variable is populated with the number of times the substitution is performed.
Number of records replaced



But $input = "plain [indent] deep [indent] deeper [/indent] deep [/indent] plain"; not an array of arrays, why you can also output strings

Return Preg_replace_callback ($regex, ' parsetagsrecursive ', $input);
In this statement, $input should not be a string?

Return Preg_replace_callback ($regex, ' parsetagsrecursive ', $input);
In this statement, $input should not be a string?


I mean, I'm saying,
if (Is_array ($input)) {
$input = ". $input [1].";
}
$input is not an array of arrays, why is it possible to output $input = '. $input [1]. This format

$input = ". $input [1].";
It's a value assignment!

is to turn $input from an array into a string

Thank you, understand. $input is exactly the same in recursion.

  • 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.