Home > Backend Development > PHP Tutorial > PHP惯用功能

PHP惯用功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:23:43
Original
884 people have browsed it

PHP常用功能

1)字符串

主要方法有:strops()、substr()、str_split()、explode()等,更多方法查看PHP官方手册;

<?php /** * 字符串的方法:strpos()、substr()、print_r()、explode() */$str="sun of beach";//获取子字符串在当前字符串的索引位置echo strpos($str,&#39;ea&#39;).&#39;<br/>';//字符串的截取$str1=substr($str,4);$str2=substr($str,4,2);echo $str1.'<br>';echo $str2.'<br>';//字符串的分割$result1=str_split($str);$result2=str_split($str,3);$result3=explode(' ',$str);print_r($result1);echo '<br>';print_r($result2);echo '<br>';print_r($result3);echo '<br>';//字符串的连接$num=500;$str3="$str <br>from Hanhan $num";echo $str3;
Copy after login



2)数组

array_push()——用来存储数组的值;

更多方法查看PHP官方手册

<?php //数组的创建:用索引创建$arr=array();$arr[0]=&#39;hello&#39;;$arr[1]=&#39;php&#39;;$arr[2]=100;$arr[3]=3.14;print_r($arr);echo &#39;<br/>';echo $arr[2];echo '<br>';//数组的创建:用key-value方式创建$arr2=array();$arr2['h']='hello';$arr2['w']='world';print_r($arr2);echo '<br>';echo $arr2['h'];echo '<br>';//数组的初始化$arr3=array(0=>'jason',1=>'see','h'=>'hello','w'=>'world','name'=>'shydzc');echo $arr3['name'];echo '<br>';//数组的常用方法$arr4=array();for($i=0;$i<img src="/img/2015/08/13/083627560.png" alt=""><br><br><p><span   style="max-width:90%"><span style="font-family:KaiTi_GB2312"><br></span></span></p><p><span style="font-family:FangSong_GB2312; font-size:18px"><br></span></p>            <div style="padding-top:20px">                     <p style="font-size:12px;">版权声明:本文为博主原创文章,未经博主允许不得转载。</p>        <div class="clear">
                 
              
              
        
            </div>
</div>
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template