PHP list,explode的使用

简介:

PHP list,explode的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?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

  

 


本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/p/5909102.html,如需转载请自行联系原作者

目录
相关文章
|
8月前
|
PHP
PHP - Laravel 查看自定义路由列表 (php artisan route:list)
PHP - Laravel 查看自定义路由列表 (php artisan route:list)
128 0
|
9月前
|
数据可视化 关系型数据库 MySQL
漏刻有时地图可视化PHP开发explode二次分离经纬度标准格式的解决方案
漏刻有时地图可视化PHP开发explode二次分离经纬度标准格式的解决方案
37 0
PHP的list()方法是干什么的?底层原理是什么?
PHP的list()方法是干什么的?底层原理是什么?
|
PHP
PHP使用explode报错:Undefined offset: 1
PHP使用explode报错:Undefined offset: 1
101 0
PHP:将list列表转为tree树形数据
PHP:将list列表转为tree树形数据
161 0
|
NoSQL 算法 安全
PHP实现令牌桶限流Redis list列表 Lpush rpop 实现令牌桶 - 限流 PHP实例
PHP实现令牌桶限流Redis list列表 Lpush rpop 实现令牌桶 - 限流 PHP实例
302 0
PHP实现令牌桶限流Redis list列表 Lpush rpop 实现令牌桶 - 限流 PHP实例
|
消息中间件 NoSQL PHP
PHP使用Redis的List(列表)命令实现消息队列
本篇笔记旨在使用Redis的List(列表)命令实现消息队列,生产者使用lPush命令发布消息,消费者使用rpoplpush命令获取消息,同时将消息放入监听队列,如果处理超时,监听者将把消息弹回消息队列
2512 0
|
PHP 索引
|
PHP
***实用函数:PHP explode()函数用法、切分字符串,作用,将字符串打散成数组
下面是根据explode()函数写的切分分割字符串的php函数,主要php按开始和结束截取中间数据,很实用 代码如下:   explode定义和用法 explode() 函数把字符串分割为数组。 语法 explode(separator,string,limit)  参数 描述 separator 必需。
1678 0