1) string
The main methods are: Strops (), substr (), Str_split (), explode (), etc., more methods to view the official PHP manual;
<?php/** * String method: Strpos (), substr (), Print_r (), Explode () */$str = "Sun of beach";//Gets a substring at the index position of the current string echo strpos ($str , ' EA '). ' <br/> ';///String intercept $str1=substr ($STR, 4); $str 2=substr ($str, 4,2); Echo $str 1. ' <br/> '; Echo $str 2. ' <br/> ';//String Segmentation $result1=str_split ($STR); $result 2=str_split ($str, 3); $result 3=explode (", $str);p Rint_r ($ RESULT1), echo ' <br/> ';p rint_r ($result 2), echo ' <br/> ';p rint_r ($result 3); Echo ' <br/> ';//String Connection $ num=500, $str 3= "$str <br/>from hanhan $num"; Echo $str 3;
2) Array
Array_push ()--used to store the values of the array;
more ways to view Official PHP manual ;
<?php//Array creation: Create $arr=array () with index, $arr [0]= ' hello '; $arr [1]= ' php '; $arr [2]=100; $arr [3]=3.14;print_r ($arr); Echo ' <br/> '; Echo $arr [2];echo ' <br/> ';//creation of arrays: Create $arr2=array with Key-value mode; $arr 2[' h ']= ' hello '; $arr 2[' W ']= ' World ';p Rint_r ($arr 2); Echo ' <br/> '; echo $arr 2[' h '];echo ' <br/> ';//initialization of the array $arr3=array (0=> ' Jason ', 1 = > ' See ', ' h ' = ' hello ', ' w ' = ' world ', ' name ' = ' shydzc '); Echo $arr 3[' name '];echo ' <br/> ';//array of common methods $ Arr4=array (); for ($i =0; $i <10; $i + +) { Array_push ($arr 4, ' item '. $i);} Print_r ($arr 4);
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PHP Common Features