PHP String Functions – Strrev, strlen, implode, trim


PHP string functions 1. substr() · 2. strlen() · 3. str_replace() · 4. trim() · 5. strpos() · 6. strtolower() · 7. strtoupper() · 8. is_string() Through this tutorial, we will learn the most useful PHP string functions 1. substr() · 2. strlen() · 3. str_replace() · 4. trim() · 5. strpos() · 6. strtolower() · 7. strtoupper() · 8. is_string(). If you work with php or any php framework at that time need to require basic PHP functions.

The Top 10+ Most Popular PHP String Functions

PHP has several built-in string functions. top 10+ string function in PHP :

  • Trim funcition
  • Ucfirst function
  • Ucwords function
  • Strlen function
  • Strtolower function
  • Strtoupper function
  • Lcfirst function
  • Str Replace function
  • Str Word Count function
  • Strrev function
  • Strpos function
  • Substr function
  • Implode function

PHP Trim Function

Trim function is used to removing whitespace both side of sting.

<?php
$str = " Developers! ";
echo trim($str);
?>

PHP Ucfirst Function

Ucfirst string function is used to change to sting the first word to uppercase.

<?php
echo ucfirst("hello world!");
?>
//Output
Hello world!

PHP Ucwords Function

This is used to change string each word first charactor to uppercase.

<?php
echo ucwords("hello developers");
?>
//Output
Hello Developers

PHP Strlen Function

Strlen function is used to count length of string.

<?php
echo strlen("developer");
?>
//Output
9

PHP Strtolower Function

Strtolower function is used to change lowercase of each charactor (whole string) of sting.

<?php
echo strtolower("DEVELOPER");
?>
//Output
developer

PHP Strtoupper Function

This function is used to convert uppercase of each charactor ( whole string ) of string.

<?php
echo strtoupper("testing");
?>
//Output
TESTING

PHP Lcfirst Function

This is used to make the first charactor of string to lowercase.

<?php
echo lcfirst("FINAL");
?>
//output
fINAL

PHP Str Replace Function

str_replace function is used to replace the value

<?php
echo str_replace("program","developer","Hello program!");
?>
// output
Hello developer

PHP Str Word Count Function

Str to word function is used to count the number of words in string.

<?php
echo str_word_count("Hello first my name is developer");
?>
// output
6

PHP Strrev Function

Strrev function is used to reversing the string. Use it for reversed to sting.

<?php
echo strrev("Hello");
?>
// output
olleh

PHP Strpos Function

Strpos function is used to find the text in string . If it find the text in string return true or false.

<?php
echo strpos("Welcome to india","india");
?>
// output
11

PHP Substr Function

Substr function is used to show(display) exact words in string.

<?php
echo substr("Hello my name is developer",0,5);
?>
//Output
Hello

PHP  Implode() Function

This function is change array to string :

<?php
$arr = array('Hello','Developers!');
echo implode(" ",$arr);
?>
//Output
Hello Developers

In this php string functions tutorial, we have learned the common useful PHP string functions.

Recommended Tutorials

If you have any questions or thoughts to share, use the comment form below to reach us.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?