php中对字符串的基本操作
2014-02-04 16:00
429 查看
(1)分割字符串
//利用 explode 函数分割字符串到数组
//split函数进行字符分割
// 分隔符可以是斜线,点,或横线
//利用 explode 函数分割字符串到数组
<?php $source = "hello1,hello2,hello3,hello4,hello5";//按逗号分离字符串 $hello = explode(',',$source); for($index=0;$index<count($hello);$index++) { echo $hello[$index];echo "</br>"; } ?>
//split函数进行字符分割
// 分隔符可以是斜线,点,或横线
<?php $date = "04/30/1973"; list($month, $day, $year) = split ('[/.-]', $date); echo "Month: $month; Day: $day; Year: $year<br />\n"; ?>
相关文章推荐
- output array
- PHP笔记(9)菜鸟攻防
- PHP笔记(8)数组定义与遍历
- 记一次lnmp环境下无法执行php文件
- php 生成唯一ID
- php5.3 新特性
- set timing on与set serveroutput on
- Zend Studio 无法打开的解决办法
- PHP截取含中文的混合字符串长度的函数
- PHP全角半角转换函数
- 获取生日对应星座的PHP函数
- php stripslashes和addslashes的区别
- php获取网页标题和内容函数(不包含html标签)
- PHP-深入学习Smarty
- PHP正则表达式提取网页的超链接及标题
- 如何合并Amazon AWS EMR产生的output文件
- php获取网页标题和内容函数(不包含html标签)
- php stripslashes和addslashes的区别
- PHP preg_replace() 正则替换所有符合条件的字符串
- PHP下获取上个月、下个月、本月的日期(strtotime,date)