Home >Backend Development >PHP Tutorial >Commonly used interception operations for strings in php

Commonly used interception operations for strings in php

WBOY
WBOYOriginal
2016-07-29 09:02:041141browse

Due to recent development needs, after encrypting the password with MD5, it involves intercepting the ciphertext string. So I wrote this blog, I hope everyone will support it.

//Constructed string
$str = "ajafafpaffafdfdfd";
echo "Original string".$str."";
$str1 = substr($str,5) ;
echo "Truncate from the fifth character to the last ".$str1."";
$str2 = substr($str,0,4);
echo "Take 4 characters from the 0th character:" .$str2."";
$str3 = substr($str,-5);
echo "Take the last 5 characters:".$str3."";
$str4 = substr($str,-8,4 );
echo "Truncate 4 characters starting from the 8th character from the bottom:".$str4."";
$str5 = substr($str,-8,-2);
echo "Start from the 8th character from the bottom Start intercepting the last 2 characters: ".$str5."";
?>

The above introduces the commonly used interception operations of strings in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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
Previous article:nginx operationsNext article:nginx operations