Blogger Information
Blog 35
fans 2
comment 0
visits 22565
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组排序,转换和替换---4月18日作业
小学僧的博客
Original
596 people have browsed it

实例

<style type="text/css">
	hr{
		padding: 0px;
		margin: 5px 0px;
		width: 650px;
	}
</style>
<?php
$test=array("JAVA","PHP","HTML","CSS","C++","Mysql");
print_r($test);
echo "<hr>";
sort($test);//sort升序排列
print_r($test);
echo "<hr>";
//sort降序排列
$test=array("JAVA","PHP","HTML","CSS","C++","Mysql");
rsort($test);
print_r($test);
echo "<hr color='gray'>";

$test2=array("Nginx"=>"2","IIS"=>"3","Apache"=>"1");
print_r($test2);
echo "<hr>";
//asort根据值升序排列
asort($test2);
print_r($test2);
echo "<hr>";
//arsort根据值降序排列
$test2=array("Nginx"=>"2","IIS"=>"3","Apache"=>"1");
arsort($test2);
print_r($test2);
echo "<hr>";
//ksort根据键升序排列
$test2=array("Nginx"=>"2","IIS"=>"3","Apache"=>"1");
ksort($test2);
print_r($test2);
echo "<hr>";
//krsort根据键降序排列
$test2=array("Nginx"=>"2","IIS"=>"3","Apache"=>"1");
krsort($test2);
print_r($test2);
echo "<hr color='gray'>";
//长度
echo strlen("  www.php.cn中文网!  ");
echo('<hr color="gray">');
//替换
$test3="www.php.cn!";
echo str_replace("php","html",$test3);
echo '<hr color="gray">';

$test4="hello";
echo('origin: '.$test4.'<br>');
echo('split: ');
print_r(str_split($test4));
echo('<br>split by 2: ');
print_r(str_split($test4,2));
echo '<hr color="gray">';
//分割
$str = 'test1,test2,test3,test4';
echo('origin: '.$str.'<br>');
print_r(explode(',',$str,2));
echo '<br>';
print_r(explode(',',$str,4));
echo '<br>';
print_r(explode(',',$str,-2));
echo '<hr color="gray">';

$str1=array("www",".php.cn");
echo implode("",$str1);

运行实例 »

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


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