PHP:数组解包(php_verions=7.4.1)
作者:互联网
<?php // phpinfo(); class array_object { private array $array_obj = []; public function set_array(array $k=[]){ $this -> array_obj = $k; } public function get_array(){ return $this->array_obj; } public function display_array(){ echo "array :="; foreach($this->array_obj as $key=>$value){ echo " $value"; } echo " ".PHP_EOL; } } function print_array(array $in){ echo "array :="; foreach($in as $key=>$value) { echo " $value"; } echo " " . PHP_EOL; } // 创建“array_object”实例 $tmp = new array_object(); $tmp -> set_array(["Gou", "TianQiao", "QiChe"]); // 数组解组 “...array_name” $tmp_in = ["Wukong", ...$tmp->get_array() ]; // 显示数组数据 print_array($tmp_in); ?>
// 输出结果 array := Wukong Gou TianQiao QiChe
标签:tmp,function,obj,verions,解包,echo,value,array,php 来源: https://www.cnblogs.com/lnlidawei/p/15647943.html