当前位置:网站首页>Use of compact, extract and list functions in PHP
Use of compact, extract and list functions in PHP
2022-06-13 03:15:00 【wks19891215】
<?php
//compact Combine variables into an array
$key_1 = "val_1";
$key_2 = "val_2";
$data = array('$key_3'=>'val_3','$key_4'=>'val_4');
$arr_n =compact('key_1','key_2','data');
echo "compact:\n";
//extract Export variables based on key names
echo "extract:\n";
$arr_str = array('key_a'=>'val_a','key_b'=>'val_b','key_arr'=>array('1','2','3'));
extract($arr_str);
var_dump($key_a);
var_dump($key_b);
var_dump($key_arr);
// list( Only works on indexed arrays ) Used to fetch data . Only part of the data can be extracted , If only the first two are taken out
echo "list:\n";
$arr_data =array('data_1','data_2','data_3','data_4');
list($v1,$v2)=$arr_data;
var_dump($v1);
var_dump($v2);
//list Variables can also be placed in the specified position of the array
list($data_res['0'],$data_res['5'])=$arr_data;
var_dump($data_res);
?>
边栏推荐
- Stack information, GC statistics
- Redis server configuration
- HEAP[xxx.exe]: Invalid address specified to RtlValidateHeap( 0xxxxxx, 0x000xx)
- Ijkplayer source code - setting option 2
- P1048 [noip2005 popularization group] Drug collection
- Simple use of qtreeview of QT (including source code + comments)
- Linked lists: rearranging linked lists
- 【pytorch 记录】pytorch的变量parameter、buffer。self.register_buffer()、self.register_parameter()
- JVM JMM (VI)
- How to manage the IT R & D department?
猜你喜欢
Applet image component long press to identify supported codes
This article takes you to learn DDD, basic introduction
Prometheus node_exporter安装并注册为服务
Es and kibana deployment and setup
Spoon database insert table operation
Wechat applet coordinate location interface usage (II) map interface
技术博客,经验分享宝典
Data Governance Series 1: data governance framework [interpretation and analysis]
MySQL index optimization (4)
2021-08-30 distributed cluster
随机推荐
Level II C preparation -- basic concepts of program design
【同步功能】2.0.16-19 版本都有同步功能修复的更新,但未解决问题
C method parameter: params
C simple understanding - generics
Data Governance Series 1: data governance framework [interpretation and analysis]
. New features in net 6.0 _ What's new in net 6.0
Querywrapper constructor method
English grammar_ Mode adverb position
C 10 new features_ C 10 new features
Differences between XAML and XML
Linked lists: rearranging linked lists
MySQL index bottom layer (I)
Stack information, GC statistics
Mongodb index -index
Beginner development process_ Project development FAQs
C method parameter: out
String: number of substring palindromes
2-year experience summary to tell you how to do a good job in project management
Code d'initialisation de l'arbre binaire
Operating principle of JS core EventLoop