PHP Free Tutorial

String functions in PHP

In PHP, Programming by Baqir Ali

There are some built-in string functions in PHP that are already defined. These functions are used to make development fast and easy such as converting from lower to upper and from upper to lower cases.

To Lower Case

<?php echo (strtolower($thirdString)); ?>

To Upper Case

<?php echo (strtoupper($thirdString)); ?>

To Upper Case First Letter

<?php echo (ucfirst($thirdString)); ?>

Uppercase words

<?php echo (ucwords($thirdString)); ?>

Length

<?php echo (strlen($thirdString)); ?>

Trim

<?php 
     echo ($fourthString . "ss<br/>"); 
     echo (trim( $fourthString)."SS"); 
?>

Find

<?php echo(strstr($firstSrting, "aa")); ?>

Replace

<?php echo(str_replace("of", "AA",
$firstSrting));?>

Repeat

<?php echo(str_repeat($firstSrting, 3)); ?>

Substring

<?php echo(substr($firstSrting, 3, 5)); ?>

String Position

<?php echo(strpos($firstSrting, "of")); ?>

Char Position

<?php echo(strchr($firstSrting, 'o')); ?>

Support us by sharing this post