English 中文(简体)
PHP阵列,从单体序列化,既包括工作,又是正确的?
原标题:PHP array from jquery serialize, both work but which is correct?
  • 时间:2011-10-04 21:53:33
  •  标签:
  • php
  • arrays

我正在利用这一方法,通过json,从jquery到一个营地。

    $navMenuLayout = array();
parse_str($layout[ navMenu ], $navMenuLayout);
print_r($navMenuLayout);

但是,我注意到,如果我走了第一行,那么我还是获得同样的产出,第一行问题吗?

parse_str($layout[ navMenu ], $navMenuLayout);
print_r($navMenuLayout);
最佳回答

当然,由于购买力平价自动设定,你不必预先确定这一职能的变量。

See example from PHPnet. for what when the second debate is defined/un Defin:

<?php
$str = "first=value&arr[]=foo+bar&arr[]=baz";
parse_str($str);
echo $first;  // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz

parse_str($str, $output);
echo $output[ first ];  // value
echo $output[ arr ][0]; // foo bar
echo $output[ arr ][1]; // baz

?>

因此,如果你没有界定第二个论点,则每一关键=和;地壳中数值均被归入实际变量,而如果你界定一个有待确定的变量,则将它们归入一个阵列,作为这一变量。 购买力平价将自动为这一功能创造一切,你不必预先确定任何东西。

问题回答

界定了parse_str:

http://www.ohchr.org。

阵列论点上的方括号将其称为任择性的。 <代码>& 标注它是一个参考论点,意味着如果从呼吁守则中通过一个变量,就会形成一个阵列。

因此,要么是正确的,但首先要告诉法律的任何保存者,如果你期望从职能呼吁中转出/重新定位,而不必在手册中加以研究,则更何况。

The $navMenuLayout = array(); declares the variable. You can get away without declaring it first but if you have notices enabled in your php.ini error configuration, you ll get a notice informing you that an undeclared variable is being used (see http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting for setting your error logging levels).

<代码>navMenuLayout通过该功能取代该功能的价值。

If you look at http://www.php.net/parse_str , you ll see in the declaration that there is an & before the variable name: parse_str ( string $str [, array &$arr ] ). This means that the variable being passed will be over-written.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签