This article mainly introduces the string processing skills in the PHP Getting Started Tutorial, combined with the instance form, this paper summarizes and analyzes the php operation techniques for deleting spaces, converting, filtering, parsing, splitting, searching, intercepting, replacing, obtaining, judging, and calculating strings for strings, for more information about PHP string processing skills, see the examples in this article. We will share this with you for your reference. The details are as follows:
Demo1.php
'; Echo rtrim ($ str); echo'
'; // Clear echo trim ($ str) on both sides; // echo chop ($ str);?>
Demo2.php
Demo3.php
Who asked Junyi.'; // Echo htmlentities ($ str); // you only need to convert special characters. // echo htmlspecialchars ($ str );//Who asked Junyi.Echo strip_tags ($ str); // who asked Junyi?
Demo4.php
Demo5.php
Demo6.php
'; echo str_pad($str,18,'#',STR_PAD_LEFT); echo '
'; echo str_pad($str,18,'#',STR_PAD_RIGHT);/** * ####oneStopWeb#### * ########oneStopWeb * oneStopWeb######## * */?>
Demo7.php
OneStopWeb [1] => 163.com) // after the split, after a round of filtering, I need to re-combine // $ arr = array ('onestop', '@', '163. com '); // $ str = implode (' & ', $ arr); // echo $ str; // oneStop & @ & 163.com $ str = implode ('-', $ email); echo $ str; // oneStopWeb-163.com?>
Demo8.php
I [1] => will [2] => be [3] => back) $ str = 'I, will. be # back'; $ tok = strtok ($ str ,',. # '); // echo $ tok; while ($ tok) {echo $ tok.'
'; $ Tok = strtok (',. # ');} // $ str =' I will be back'; // $ tok = strtok ($ str, ''); // echo $ tok; // while ($ tok) {// echo $ tok.'
'; // $ Tok = strtok (''); //} // $ tok = strtok (''); // echo $ tok; // Iwill // the pointer is not moved down, but is returned again // $ tok = strtok ($ str, ''); // echo $ tok;?>
Demo9.php
Demo10.php
Demo11.php
Demo12.php
Demo13.php
Demo14.php
Demo15.php
Demo16.php
Demo17.php
Demo18.php
Demo19.php
Demow.php
Demo21.php
Demo22.php
I hope this article will help you with PHP programming.
For more articles on string processing techniques (conversion, filtering, parsing, searching, intercepting, replacement, etc.) in the PHP Getting Started Tutorial, please follow the PHP Chinese website!