实例
<?php echo '<p>字符串函数(三):字符串与数组之间的转换</p><hr color="green">'; /医院 * 1.str_split($str,$length) * 2.explode($delimiter,$str,$num) * 3.imglode($glue,$str) */ echo '<pre>'; $str = 'html,css,jquery,php,mysql,thinkphp'; echo '<p>原始字符串:'.$str.'</p>'; //1.str_split($str,$length) //print_r(str_split($str)); print_r(str_split($str,5)); // echo count(str_split($str)); echo '<hr color="red">'; //2.explode($delimiter,$str,$num) print_r(explode(',',$str)); print_r(explode(',',$str,5)); //3/implode($glue,$str):按分隔符,将一堆数组拼装成字符串 $arr2 = explode(',',$str); print_r($arr2); echo implode(',',$arr2),'<br>'; echo implode('医院*',$arr2),'<br>'; echo implode('',$arr2),'<br>';
运行实例 »
点击 "运行实例" 按钮查看在线实例