PHP – Modify Strings

PHP offers a variety of built-in functions to modify strings.

Tutorials dojo strip

Convert to Upper Case

The strtoupper() function converts a string to upper case.

Example:

PHP

Convert to Lower Case

The strtolower() function converts a string to lower case.

Example:

PHP

Replace String Content

The str_replace() function replaces specific characters in a string with other characters.

Example:

Replace “Ferrari” with “Lamborghini”:

PHP

Reverse a String

The strrev() function reverses the characters in a string.

Example:

PHP

Remove Whitespace

Whitespace refers to any spaces before and after the actual text. The trim() function removes these spaces.

Example:

PHP

Convert String to Array

The explode() function splits a string into an array based on a specified separator.

Example:

Split the string into an array using space as a separator:

PHP
Tutorials dojo strip