Blogger Information
Blog 87
fans 0
comment 0
visits 59713
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
4月18日作业: 字符串与数组之间的转换
黄忠倚的博客
Original
805 people have browsed it

实例

<?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>';

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post