Blogger Information
Blog 39
fans 0
comment 0
visits 34594
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组与字符串的常用方法-4月18日作业
美丽城堡
Original
531 people have browsed it

实例

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>PHP 中数组的遍历</title>
   <link rel="stylesheet" href="http://1.meleezhao.applinzi.com/storm/ross.css">
   
    
</head>
<body>
    <header>PHP 中数组的遍历</header>
    <div class="wrap">
       <?
        $a = array('one','two','name',1,2,false,[11,22],true);
 		echo '<div><p>sort() 对数组进行排序,默认按数值进行排序:<pre>';
        sort($a);
        print_r($a);
        var_dump($a);
        echo '</pre></p>';
        
    
        echo '<p>按ASSC 码值排序:<pre>';
        	sort($a,SORT_STRING);
        	print_r($a);
        echo '</pre></p>';
        
        
        $string = 'where are you';
        echo '<p> 字符串长度方法: strlen()<pre>';
        echo $string."\n";
        echo '数组的长度是:',strlen($string);
       echo '</pre></p>';
        
        //字符串与数组间的转换
        $a2 = str_split($string);
        echo '<p>字符串转换成数组<pre>';
        print_r($a2);
       	echo '</pre></p>'; 
       
        echo '<p><pre>';
        $a3 = str_split($string,3);
       	print_r($a3);
        echo '<br/>';
        var_dump($a3);
        echo '</pre></p>';
        
        echo '<p><pre>';
        $a4 = explode(' ',$string);
        print_r($a4);
        echo '</pre></p>';
        echo '</div>';
        
        
        echo '<p>将数组转换为字符串</p>';
        $a5 = array('long','time','no','see','!!');
        $string2 = implode(' ',$a5);
        print_r($a5);
        echo '<hr>';
        echo $string2;
        ?>
    </div>
    <footer>End..</footer>
</body>
</html>

运行实例 »

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


Correction status:Uncorrected

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