Blogger Information
Blog 36
fans 0
comment 1
visits 28081
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字符串函数
其琛的博客
Original
809 people have browsed it
<?php 
echo "<h3>常用的数组函数</h3>";
echo '<hr color="red">';
$a=['id'=>001,'name'=>'ooho', 'course'=>'php','grend'=>90,5=>true];
echo "<h4 align=\"center\">数组排序</h4>";
echo '<hr color="red">';
print_r($a);
echo '<hr color="red">';
// 原始数组
sort($a);
print_r($a);
// 正序,索引键改变,键名重置
echo '<hr color="red">';
asort($a, SORT_NUMERIC);
print_r($a);
// 索引键不变的正序
echo '<hr color="red">';
ksort($a);
print_r($a,SORT_STRING);
echo '<hr color="red">';
rsort($a);
print_r($a);
// 反转
echo '<hr color="red">';
arsort($a);
print_r($a);
echo '<hr color="red">';
krsort($a);
print_r($a);
echo '<hr color="red">';
echo "<h4 align=\"center\">数组函数字符串长度</h4>";
$b='php中文网';
echo $b;
echo '<hr color="red">';
echo strlen($b);
echo '<hr color="red">';
echo mb_strlen($b,mb_internal_encoding());
echo "<h4 align=\"center\">数组函数字符串比较运算</h4>";
$str1 = 'php中文网';
$str2 = 'PHP中文网';
echo strcmp($str1, $str2) == 0 ? '两个变量相等' : '两个变量不相等'; 
echo '<hr color="red">';
// echo strncmp($str1, $str2) == 0 ? '两个变量相等' : '两个变量不相等'; 
// echo '<hr color="red">';
// echo strcasecmp($str1, $str2) == 0 ? '两个变量相等' : '两个变量不相等'; 
// echo '<hr color="red">';
// echo strncasecmp($str1, $str2) == 0 ? '两个变量相等' : '两个变量不相等'; 
// echo '<hr color="red">';
echo "<h4 align=\"center\">字符串与数组之间的转换</h4>";
echo "<pre>";
$c='a,b,c,d,e,f,g,h,i';
print_r(explode(',',$c));
echo '<hr color="red">';
print_r(explode(',',$c,2));
$d=['q','w','e','r','t','y','u','i','o'];
echo '<hr color="red">';
echo implode(',***,', $d);
echo "<h4 align=\"center\"> 字符串的查找与替换</h4>";
echo '<hr color="red">';
$e='www.baidu.com';
echo strpos($e, 'w',2);
echo '<hr color="red">';
echo strstr($e, 'php'),'<br>';
echo strstr($e, 'php',true);
echo '<hr color="red">';
echo str_replace('baidu','google',$e);
echo '<hr color="red">';
echo substr_replace($e,'cn', 10, 3); 




 ?>

手写如图qq_pic_merged_1524135289445.jpg样式Z6N_62K)$W(VPPWDOJ7}FLN.png

Correction status:qualified

Teacher's comments:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!