Blogger Information
Blog 14
fans 0
comment 1
visits 6527
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
8月24日作业
狼图腾的博客
Original
563 people have browsed it

实例

<meta charset="utf-8">
<!--一、数组数组与字符串变量之间的转换-->
<h3>数组与字符串变量之间的转换</h3>
<?php
list($name, $course, $grade) = ['小龙女','php',80];
echo $name,'的"',$course,'"课程成功是:',$grade ,'<hr>';
//关联数组
$arr1 = ['id'=>1,'name'=>'杨过','sex'=>'male','salary'=>8000];
echo var_export(extract($arr1),true);
echo $id,$name,$sex,$salary;
echo '<hr>';
//3.compact(): 将变量转为关联数组
$name = '陈近南';
$fation = '天地会';
$position = '总的主';
$arr = compact('name','fation','position');
echo var_export($arr,true),'<hr>';
//4.explode 将字符串转换成数组
echo '<pre>';
$lang = 'c,php,c++,java,css,go';
echo var_export(explode(',',$lang)),'<br>';
echo var_export(explode(',',$lang,3)),'<br>';
echo var_export(explode(',',$lang,-2)),'<br>';
//5.implode  分散拼接
$arr = ['good','morning','big','and'];
echo var_export(implode('_',$arr));
//二、数组元素回掉
$arr1 = [5,2,'',null,22,false,'php'];
echo '<pre>';
echo var_export($arr1,true),'<br>';

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post