PHP character substitution, interception, specifying lookup

Source: Internet
Author: User

<?php
/**
* Created by Guopeng.
* User:msi
* DATE:2017/9/27
* Time:14:17
*/

Random number generator
EchoRAND ();
Echo"<br>";
Generate a range of random numbers
EchoRand0,10);
Echo"<br>";
Gets the current time stamp
EchoTime ();
Echo"<br>";
Format the display of time
Echo"<br>";
EchoDate"Y-m-d h:i:s",Time ());
Echo"<br>";
EchoDate"Y-m-d h:i:s","1506494976");
String converted to Timestamp
Echo"<br>";
EchoStrtotime ("2017-09-27 14:37:39");
Echo"<br>";

Take the length of the string
$str 1="ABCDEFG";
$str 2="ABC";
Echo strlen ();
Echo"<br>";
Compare two strings, US standard code for information interchange;
Var_dump (strcmp ($str 1,$str 2));
Turn lowercase
Echo"<br>";
Strtolower ($str 2);
Turn capital
Strtoupper ();
Splitting a string
Echo"<br>";
Var_dump (Explode ("B",$str 2));

Stitching array elements into a single string
Echo"<br>";
EchoImplode ("|",[A,"B",C]);

Replace replace
Echo"<br>";
Here is the return value, so use the echo output;
EchoStr_replace ("CD","CD",$str 1);
Echo"<br>";
Echo$str 1;

Replaces a string at the specified position
Echo"<br>";
EchoSubstr_replace ($str 1,"XXX",0,3);

Intercept string
Echo"<br>";
EchoSubstr$str 1,1,3 ) ;

//Regular expression
$str =<<<a
456abcdefghijklmn123
A ;
echo "<br>" ;
//the number of all characters above is replaced with #
echo Preg_replace ( "/\d/" , "#" , $str ) ;

/span>

Substitution of PHP characters, intercepting, specifying find

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.