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

分割字符串 //利用 explode 函数分割字符串到数组
<div class="codetitle"><a style="CURSOR: pointer" data="56069" class="copybut" id="copybut56069" onclick="doCopy('code56069')"> 代码如下:

<div class="codebody" id="code56069">
<?PHP
$source = "hello1,hello2,hello3,hello4,hello5";//按逗号分离字符串
$hello = explode(',',$source); for($index=0;$index<count($hello);$index++)
{
echo $hello[$index];echo "
";
}
?>

//split函数进行字符分割
// 分隔符可以是斜线,点,或横线
<div class="codetitle"><a style="CURSOR: pointer" data="47783" class="copybut" id="copybut47783" onclick="doCopy('code47783')"> 代码如下:
<div class="codebody" id="code47783">
<?PHP
$date = "04/30/1973";
list($month,$day,$year) = split ('[/.-]',$date);
echo "Month: $month; Day: $day; Year: $year
\n";
?>
通过数组实现多条件查询代码<div class="codetitle"><a style="CURSOR: pointer" data="25757" class="copybut" id="copybut25757" onclick="doCopy('code25757')"> 代码如下:
<div class="codebody" id="code25757">
<?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;

分割字符串

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...