Character string processing skills in the PHP getting started tutorial. For more information, see filter, parse, search, intercept, and replace)

Source: Internet
Author: User
Tags strtok
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!

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.