work hard work smart

专注于Java后端开发。 不断总结,举一反三。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

PHP list,explode的使用

Posted on 2016-09-26 14:29  work hard work smart  阅读(1627)  评论(0编辑  收藏  举报

PHP list,explode的使用

<?php
header("Content-type: text/html; charset=utf-8");
echo "explode 使用<br>";
$student = "Zhangsan,Lisi,Wangwu";
$studentArray=explode(",",$student);
echo $studentArray[0]."<br>";
echo  $studentArray[1]."<br>";

echo "<br>list 使用<br>";
list($stu1,$stu2,$stu3) = explode(",",$student);
echo $stu1."<br>";
echo $stu2."<br>";
echo $stu3."<br>";
?>

1.header("Content-type: text/html; charset=utf-8"); 解决中文乱码问题。

输出结果:

explode 使用
Zhangsan
Lisi

list 使用
Zhangsan
Lisi
Wangwu