The multidimensional array constructed by the HTML page cannot get the value on the server side

Source: Internet
Author: User
The project uses thinkphp, the front-end framework with DWZ, the page constructs a two-dimensional array, as follows:

After submitting, print Noticetype This array, the result is:
Array
(

[9353] => Array    (        ['msg'] => msg    )[9784] => Array    (        ['wechat'] => wechat    )[10113] => Array    (        ['email'] => email    )

)

However, when using a loop to iterate over the above array, or output:
"$_post\[noticetype\]\[9784\][\ ' wechat\" this format
Instead of using a two-dimensional array for post?
Why can I print a complete two-dimensional array and not get a single value?

Reply content:

The project uses thinkphp, the front-end framework with DWZ, the page constructs a two-dimensional array, as follows:

After submitting, print Noticetype This array, the result is:
Array
(

[9353] => Array    (        ['msg'] => msg    )[9784] => Array    (        ['wechat'] => wechat    )[10113] => Array    (        ['email'] => email    )

)

However, when using a loop to iterate over the above array, or output:
"$_post\[noticetype\]\[9784\][\ ' wechat\" this format
Instead of using a two-dimensional array for post?
Why can I print a complete two-dimensional array and not get a single value?

Use your given data to simulate the problem of adding quotes to the values in the array when you submit the table.
I'll show you what I wrote with your data:


  
   ";    print_r($_POST);    echo "
"; echo "-----------------------------------------------"."

"; echo $_POST['noticetype'][9353]['msg']."
"; echo $_POST['noticetype'][9784]['email']."
"; echo $_POST['noticetype'][10113]['wechat']."
"; echo "---------------------------------------------"."

"; foreach ($_POST['noticetype'] as $key => $value) { foreach ($value as $k => $v) { echo $v.'
'; } }} ?> index

Results show:

If you enclose the MSG in quotation marks , the Foreach loop can fetch the value but $_POST['noticetype'][9353]['msg'] not the value.

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