How to Replace String in PHP, How to do, Top 1o Lists, Hacking, Games, Pictures, Tips and Tricks, PHP, Movies.

How to Replace String in PHP

PHP language has an function which is used to replace a string with another string.

This Function is worked by following Syntax:

str_replace(find,replace,string,count)

Parameters:

Find Required and used for the find value.
Replace Required and used for the replace value.
String Required and this is the value where string will be find and replace.
Count Optional and this is an variable which count the number of replacement.

Examples:

<?php echo str_replace(“Hello”,”Hi”,”Hello World!”; ?>

Output:

Hi World!

In this example String ” Hello ” is replaced String ” Hi ” in String ” Hello World! “.

Tips and Warnings:

  • This function is case sensitive

Related posts:

Tags: , , , , , , , , , , , , , , , , , , ,
© 2012 Ataaso. All rights reserved.
Read » How to Replace String in PHP Article, Top Ten List, Wordpress Hack, Programming Tricks, Amazing Pictures