Application of input Array in PHP

Source: Internet
Author: User

Generally when we use input to pass form data, we can use <input name= "xxx[" value= "1" ><input name= "xxx[]" value= "2", to get $_post[' xxx '] As an array object, the data correspondence relation is related to the order of input in the form.

If you want to use an array of the specified key value, you can use <input name= "Xxx[a" value= "1" ><input name= "xxx[b]" value= "2" > This form, the resulting data is $_post[' xxx ' [' A '],$_post[' xxx ' [' B '], which corresponds more accurately.

PS, in the name of input enter the key value is not to call single or double quotation marks, such as name= "xxx['b'", because the resulting key will be escaped to]\ ' A\ ', the general use is also acceptable, But how to get the form data in and out of the file, like

$INDEXTDK = I ("POST.INDEXTDK");
$OTHERTDK = I ("POST.OTHERTDK");

File_put_contents ($this->uconfig_path. ' tdk.php ', ' <?php '. Php_eol. "Return". Var_export (' index ' = $INDEXTDK, ' other ' = $OTHERTDK],true). ‘;‘);

In these forms, the saved data is not very good and becomes

<?php
Return Array (
' Index ' =
Array (
' \ ' title\ ' ' = ' 111 ',
' \ ' desc\ ' ' = ' 2222 ',
' \ ' key\ ' ' = ' 3333 ',
),
' Other ' =
Array (
' \ ' title\ ' ' = ' 1166 ',
' \ ' desc\ ' ' = ' 2266 ',
' \ ' key\ ' ' = ' 3466 ',
),
);

Record the warning

Application of input Array in PHP

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.