extract()函数语法:
int extract( array $var_array [, int $extract_type = EXTR_OVERWRITE [, string $prefix ]] )
功能: extract()函数提取关联数组(对数字索引数组无效)每对key和value,生成以key为变量名、value为对应值的多组新变量。
复制代码 代码如下:
$size = "old size"; //注意最后size变量的值。
$a = array(
"color" => "red",
"size" => "XXL",
"price" => "53");
extract($a);
echo "color = $color
";
echo "size = $size
";
echo "price = $price
";
?>
复制代码 代码如下:
$a = array(
"color" => "red",
"size" => "XXL",
"price" => "53");
extract($a,EXTR_PREFIX_ALL,"SC");
echo "color = $SC_color
";
echo "size = $SC_size
";
echo "price = $SC_price
";
extract($a,EXTR_REFS);
$color="green";
echo $a['color']; //查看原数组的值
?>
以上就介绍了extractdata PHP extract 将数组拆分成多个变量的函数,包括了extractdata方面的内容,希望对PHP教程有兴趣的朋友有所帮助。