: This article mainly introduces common PHP functions. if you are interested in the PHP Tutorial, you can refer to it. 1) string
The main methods include strops (), substr (), str_split (), and explode (). For more methods, see the official PHP Manual;
'; // String truncation $ str1 = substr ($ str, 4); $ str2 = substr ($ str, 4, 2); echo $ str1 .'
'; Echo $ str2 .'
'; // String segmentation $ result1 = str_split ($ str); $ result2 = str_split ($ str, 3); $ result3 = explode ('', $ str ); print_r ($ result1); echo'
'; Print_r ($ result2); echo'
'; Print_r ($ result3); echo'
'; // String connection $ num = 500; $ str3 = "$ str
From Hanhan $ num "; echo $ str3;
2) array
Array_push () -- used to store array values;
For more information, see the official PHP Manual;
'; Echo $ arr [2]; echo'
'; // Create an array: use key-value to create $ arr2 = array (); $ arr2 ['H'] = 'hello '; $ arr2 ['w'] = 'world'; print_r ($ arr2); echo'
'; Echo $ arr2 ['H']; echo'
'; // Array initialization $ arr3 = array (0 => 'Jason', 1 => 'sees ', 'H' => 'hello ', 'W' => 'world', 'name' => 'shyzc'); echo $ arr3 ['name']; echo'
'; // Common array methods $ arr4 = array (); for ($ I = 0; $ I <10; $ I ++) {array_push ($ arr4, 'item '. $ I);} print_r ($ arr4 );
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above describes common PHP functions, including related content, and hopes to help those who are interested in PHP tutorials.