php中利用explode函数分割字符串到数组

2015-01-24信息快讯网

这篇文章主要介绍了php中利用explode函数分割字符串到数组,需要的朋友可以参考下

分割字符串

//利用 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"; 
?> 


通过数组实现多条件查询的代码

<?php
$keyword="asp php,jsp";
$keyword=str_replace("  "," ",$keyword);
$keyword=str_replace(" ",",",$keyword);
$keyarr=explode(',',$keyword); 
for($index=0;$index<count($keyarr);$index++) 
{ 
$whereSql .= " And (arc.title like '%$keyarr[$index]%' Or arc.keywords like '%$keyarr[$index]%') ";
} 
echo $whereSql;
destoon实现首页显示供应、企业、资讯条数的方法
destoon实现公司新闻详细页添加评论功能的方法
destoon数据库表说明汇总
php中的四舍五入函数代码(floor函数、ceil函数、round与intval)
PHP下通过QRCode类库创建中间带网站LOGO的二维码
PHP实现显示照片exif信息的方法
php中json_encode处理gbk与gb2312中文乱码问题的解决方法
使用ThinkPHP+Uploadify实现图片上传功能
php采用curl访问域名返回405 method not allowed提示的解决方法
PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法
浅析application/x-www-form-urlencoded和multipart/form-data的区别
php的SimpleXML方法读写XML接口文件实例解析
浅析ThinkPHP中execute和query方法的区别
PHP中使用gettext解决国际化问题的例子(i18n)
Codeigniter上传图片出现“You did not select a file to upload”错误解决办法
让codeigniter与swfupload整合的最佳解决方案
php生成excel文件的简单方法
PHP判断变量是否为0的方法
采用header定义为文件然后readfile下载(隐藏下载地址)
分享一个超好用的php header下载函数
PHP 利用Mail_MimeDecode类提取邮件信息示例
header导出Excel应用示例
用Zend Studio+PHPnow+Zend Debugger搭建PHP服务器调试环境步骤
修改apache配置文件去除thinkphp url中的index.php
PHP类继承 extends使用介绍
利用phpexcel把excel导入数据库和数据库导出excel实现
php下载excel无法打开的解决方法
PHP SPL使用方法和他的威力
PHP利用str_replace防注入的方法
php中autoload的用法总结
PHP中spl_autoload_register函数的用法总结
php preg_replace替换实例讲解
is_uploaded_file函数引发的不能上传文件问题
php float不四舍五入截取浮点型字符串方法总结
PHP error_log()将错误信息写入一个文件(定义和用法)
©2014-2024 dbsqp.com