PHP list,explode的使用

时间:2023-03-09 09:58:58
PHP list,explode的使用

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