How to String Replace Capital Letters in PHP?

03-Apr-2023

.

Admin

How to String Replace Capital Letters in PHP?

Hi Dev,

This tutorial will provide example of how to string replace capital letters in PHP. We will use capitalize in php with code examples. this example will help you PHP strtoupper() function. This tutorial will give you simple example of how to replace all uppercase letters with spacing using php. Here, Creating a basic example of change all letter to uppercase php.

Below programs illustrate the strtoupper() function in PHP. The strtoupper() is a widely used function of PHP. Below some examples are given. With the help of these examples, we can understand the working of this function practically

Example: 1


index.php

<?php

// original string

$str = "nicesnippets";

// string converted to upper case

$resStr = strtoupper($str);

print_r($resStr);

?>

Output:

NICESNIPPETS

Example: 2

index.php

<?php

$input_str = "hie! learn php post at nicesnippets.com";

$result_str = strtoupper($input_str);

echo "String after conversion: ". $result_str;

?>

Output:

String after conversion: HIE! LEARN PHP POST AT NICESNIPPETS.COM

I hope it could help you...

#PHP