Common PHP functions

Source: Internet
Author: User
Common functions of PHP 1) the main methods of strings include strops (), substr (), str_split (), and explode (). For more information, see the official PHP Manual. & lt ;? Php *** string method: strpos (), substr (), print_r (), explode () * $ str & quot; sunofbeach & quot ;; obtain common functions of a substring in the current string in PHP

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.